我正在尝试创建一个函数来解锁在指定时间之前锁定的引线。我在shell中使用聚合管道测试了updateMany函数,但是当试图从一个领域函数运行它时,我会得到一个错误.
StitchError: update:修饰符参数必须是一个对象
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是否接受领域中的聚合管道?如果是的话,我犯了错误吗?
发布于 2020-07-19 13:25:59
Hi Bernard - 聚合管道中的更新是MongoDB中一个非常新的特性(4.2版),我们正在领域函数中支持MQL到MongoDB 4.4。我们预计这将在不久的将来发布。
https://stackoverflow.com/questions/62944034
复制相似问题