Sequence: 1, twists and turns. Baidu 2 days. . . . . Almost gave up, I thought it was a mongoose problem. 2. I know that you may have reported a lot of errors, and changed other methods such as findByIdAndUpdate. 3. The blogger egg-mongoose ^ 3.3.1 version (if your version is the same as […]
Tag: mongoose
[Solved] egg-mongoose’s update only works with $operators reports an error
Full error like this Invalid key ‘user’: update only works with $operators The blogger was executing a batch write command bulkWrite code show as below db.a_boss.bulkWrite([ { updateOne:{ filter:{_id:ObjectId(“631063e1f1834a13800055d4″)}, update:{user:”11”} } }, { updateOne:{ filter:{_id:ObjectId(“631076a5f1834a13800055d5″)}, update:{user:”22”} } } ]) The solution is actually very simple, just wrap the update value with $set, as follows db.a_boss.bulkWrite([ […]