我正在尝试对文档执行批量更新插入。我知道这不能在本地完成Meteor:Mongo,必须使用 Node MongoDB librawCollection代替。
我有以下
const bulkUpserts = [];
for (let doc of docs) {
bulkUpserts.push({
updateOne: {
filter: {
fizz: doc.buzz
},
update: doc,
upsert: true,
setOnInsert: {
"foo": "bar",
"createdBy": Meteor.userId(),
"createdDate": new Date()
}
}
});
}
Collection.rawCollection().bulkWrite(bulkUpserts);
^ 的问题是它setOnInsert似乎不起作用。我foo的没有设置。看起来setOnInsert不能作为updateOne. 有什么选择呢?令人惊讶的是,我还找不到在 Meteor 中执行此操作的方法。
谢谢!
HUWWW
相关分类