-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Dev Exp
-
None
https://jira.mongodb.org/browse/MONGOID-5472 describes the original requested use case: when a model is loaded with a runtime-overridden persistence context, it should be by default saved using that persistence context, i.e. the write should be to where the instance came from.
The syntax shown in https://jira.mongodb.org/browse/MONGOID-5472 retains the block form of #with, which is awkward:
band = Band.with(collection: 'foo') { |cls| cls.first } # saves to 'foo' band.save!
It would be more convenient if #with didn't require the block in this case:
band = Band.with(collection: 'foo').first # saves to 'foo' band.save!
See discussion and partial patch in https://github.com/mongodb/mongoid/pull/4556.
- is related to
-
MONGOID-5138 Assign persistence context to Mongoid::Criteria
- Backlog
-
MONGOID-5150 Use primary read preference for validates_uniqueness_of
- Closed
-
MONGOID-5472 Save models using the overridden persistence context used for their loading
- Closed