我正在尝试创建一个函数来解锁在指定时间之前被锁定的潜在客户。我在 shell 中使用聚合管道测试了 updateMany 函数,但是当尝试从领域函数运行它时,我得到一个错误......
StitchError:更新:修饰符参数必须是一个对象
exports = function(){
const mongodb = context.services.get("mongodb-atlas");
const leads = mongodb.db("Dev").collection("leads");
const query = { lockDate: {$lte: new Date('2020-07-01T00:00:02.012Z')}, stage: "Lead" };
const update = [{ $set: {"previousOwner": "$owner", "locked": false}}, {$unset: ["owner", "lockDate"]}]
const options = { upsert: false };
return leads.updateMany(query, update, options).then(res => {
const { matchedCount, modifiedCount } = res;
console.log(`Successfully matched ${matchedCount} and modified ${modifiedCount} items.`);
return res;
}).catch(err => console.log(err));
};
updateMany 是否接受 Realm 中的聚合管道?如果确实如此,我是否犯了错误?