The Official Ruby Object Mapper for MongoDB
Mongoid 9.0 is a new major update to the Mongoid ODM. It includes many bug fixes, updates, improvements, and new features.
Significant new features include the following:
after_commit
and after_rollback
callbacks. (MONGOID-5530, MONGOID-5531 and MONGOID-5708)Mongoid.around_embedded_document_callbacks
configuration option. (MONGOID-5658)BSON::ObjectId
instances to be serialized and deserialized by ActiveJob. (MONGOID-5611)--sandbox
when starting the Rails console, your console session will be wrapped in a transaction. (MONGOID-4901)mongoid.yml
or config.rb
, and generate new data keys via rake
. (MONGOID-5585, MONGOID-5587, MONGOID-5589, MONGOID-5592, MONGOID-5613, MONGOID-5615.)Many other changes are included as well, including the following:
Mongoid.reconnect_clients
in conjunction with improving documentation about working with forking webservers. (MONGOID-5758)touch: true
. This means that when you update an embedded document, its parent is automatically touched (or saved, with the timestamps updated) as well. (MONGOID-5016)Mongoid::RawValue
. This makes it easier to deal with legacy data that does not conform to an expected type. (MONGOID-5408)rails g mongoid:config
) now additionally generates a default config/initializers/mongoid.rb
. (MONGOID-5439)#touch
on a model, Mongoid now clears the 'changed' state of the model. Previously, #touch
left the model in a 'changed' state, even though it had been persisted by the touch operation. (MONGOID-5504)db:mongoid:create_indexes
rake task was not always loading all models before creating the indexes, resulting in some missing indexes. This is now fixed. (MONGOID-5547)$min
, $max
, and $mul
operators (via set_min
, set_max
, and mul
), as well as $setOnInsert
when doing an upsert (via a new :set_on_insert
option to #upsert
). (MONGOID-5442)Time.zone=
) will now be used when typecasting dates for time-valued fields. (MONGOID-5488)BigDecimal
values. (MONGOID-5484)$in
). (MONGOID-5164)estimated_count
when a default scope is active on a collection now raises a dedicated exception (Mongoid::Errors::InvalidEstimatedCountScoping
) (MONGOID-4960)Mongoid::Errors:AttributeNotLoaded
when a program attempts to access a field that is defined on the model, but which was excluded by the query's projection. Previously, ActiveModel::MissingAttributeError
was raised in this situation. (MONGOID-5467)BSON::Document
. This makes the behavior consistent with how those fields are loaded from the database. (MONGOID-5410)Additionally, a number of methods that were monkey-patched onto core modules have been deprecated, including the following:
Array#multi_arged?
(MONGOID-5669)BigDecimal#__to_inc__
(MONGOID-5662)Hash#__consolidate__
(MONGOID-5654)Hash#__mongoid_unsatisfiable_criteria?
(MONGOID-5671)Hash#__nested__
(MONGOID-5653)Hash#delete_id
(MONGOID-5670)Hash#extract_id
(MONGOID-5670)Hash#to_criteria
(MONGOID-5677)Integer#unconvertable_to_bson?
Object#__find_args__
(MONGOID-5665)Object#__mongoize_fk__
(MONGOID-5675)Object#__setter__
(MONGOID-5664)Object#__sortable__
(MONGOID-5663)Object#__to_inc__
(MONGOID-5662)Object#blank_criteria?
(MONGOID-5671)Object#do_or_do_not
(MONGOID-5673)Object#regexp?
(MONGOID-5674)Object#you_must
(MONGOID-5673)String#mongoid_id?
(MONGOID-5668)String#unconvertable_to_bson?
(MONGOID-5667)Symbol#mongoid_id?
(MONGOID-5668)Time#configured
(MONGOID-5676)Also, Criteria#for_js
has been deprecated (MONGOID-5651), and Mongoid::QueryCache
(which was previously deprecated) has been removed (MONGOID-5625).
This patch release includes the following fixes:
MONGOID-5704: By default, associations (like belongs_to
) are validated when a document is saved. However, Mongoid was aggressively loading persisted associations and validating them, which led to a significant performance regression in Mongoid 8+ (versus Mongoid 7.x). This patch fixes this regression by only validating associations that are (1) currently in-memory, and (2) either unpersisted or modified.
MONGOID-5709: has_and_belongs_to_many associations on embedded docments were broken, and attempting to use them would result in an "InvalidPath" exception. This patch release fixes that bug.
This patch release includes the following fixes:
MONGOID-5704: By default, associations (like belongs_to
) are validated when a document is saved. However, Mongoid was aggressively loading persisted associations and validating them, which led to a significant performance regression in Mongoid 8+ (versus Mongoid 7.x). This patch fixes this regression by only validating associations that are (1) currently in-memory, and (2) either unpersisted or modified.
MONGOID-5709: has_and_belongs_to_many associations on embedded docments were broken, and attempting to use them would result in an "InvalidPath" exception. This patch release fixes that bug.
This is a patch release in 8.1.x series fixes the following issue:
We strongly recommend to upgrade to this version if you use 8.1.3.
This release also adds the following improvement:
This is a patch release in 8.1.x series that adds support for Rails 7.1.
The following issues were fixed:
This is a patch release in 8.0.x series that adds support for Rails 7.1.
The following issues were fixed:
Mongoid 8.1.2 is a patch release in the 8.1 series, addressing the following issues:
The following issue was also done, affecting only a clean-up of old documentation:
Mongoid 8.0.6 is a patch release in the 8.0 series, addressing the following issues:
The following issue was also done, affecting only a clean-up of old documentation:
Mongoid 7.5.4 is a patch release in the 7.5 series, addressing the following issues:
The following issue was also done, affecting only a clean-up of old documentation:
Mongoid 8.1.1 is a patch release in the 8.x series. It fixes the following issue:
It also corrects the following documentation error: