These are chat archives for Automattic/mongoose

Feb 2018
Feb 17 2018 21:26
My code is working fine on Node 9.3.0, Mongoose 4.13.11, Mongo 3.6.0 and mongodb driver 3.0.2.
After upgrading Mongoose to 5.0.6, I get a runtime error when calling updateOne():
MongoError: the update operation document must contain atomic operators.
The code is:
docmodel.updateOne({"_id": doc._id }, doc, {upsert: true}, (err,writeOpResult) => {
The error message makes it seem like I'm missing an operator such as $set, but if I change the code to:
docmodel.updateOne({"_id": doc._id }, { $set: doc }, {upsert: true, overwrite: true}, (err,writeOpResult) => {
Then I get a different error:
StrictModeError: Field $set is not in schema and strict mode is set to throw.
How is this supposed to work in Mongoose 5??