Closed codemeasandwich closed 4 years ago
I have found that doing multiple separate changes in one go. May not show up as distinct changes
Example
const personSchema = new Schema({ name: String, job:Schema.Types.ObjectId },{ timestamps: true }); const jobSchema = new Schema({ role: String }); const Person = mongoose.moduleStream('person', personSchema) const Job = mongoose.module('job', jobSchema) Promise.all([Person.create({name:"bob"}), Job.create({role:"baker"})]) .then(function([person,job]) { person.job = job._id person.save() }).then(console.log) .catch(console.error)
This can lead to
{ "_id" : ObjectId("5e6c96d728321a7249ace214"), "patchs" : [ { "op" : "add", "path" : "/", "value" : { "_id" : "5e6c96d728321a7249ace212", "name": "bob", "job" : "5e6c96d728321a7249ace213", "createdAt" : "2020-03-14T08:33:27.846Z", "updatedAt" : "2020-03-14T08:33:27.985Z", "__v" : 0 } } ], "target" : ObjectId("5e6c96d728321a7249ace212"), "createdAt" : ISODate("2020-03-14T08:33:27.932Z") }
Where this should be 2 adds
Fixed: https://github.com/codemeasandwich/mongoose-model-stream/commit/43ea3c16ef4afead26ec12fd477638e697cc5a89
I have found that doing multiple separate changes in one go. May not show up as distinct changes
Example
This can lead to
Where this should be 2 adds