我使用以下代码在mongo db中存储文档
const MongoClient = require('mongodb').MongoClient
MongoClient.connect(settings.DB_MONGO_CONNECTOR, (err, db) => {
if (err) throw err
this.mongoCollection = db.db(settings.DB_MONGO_TABLE)
.collection(this.mongoTableName)
})
//......
let arr = []
//......
this.mongoCollection.updateMany(arr, (err) => {
if (err) throw err
console.log('Document was saved')
}, { upsert: true })
调用updateMany后我收到错误:
(node:8228) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: The update operation document must contain at least one atomic operator.
(node:8228) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
为什么呢?它的有效命令与否?