MongoDB Stitch/Remm函数updateMany出现聚合错误



我正在尝试创建一个函数来解锁在指定时间之前锁定的潜在客户。我在shell中用聚合管道测试了updateMany函数,但当试图从Realm函数运行它时,我遇到了一个错误。。。

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在Realm中接受聚合管道吗?如果是的话,我犯了错误吗?

Hi-Bernard–聚合管道内的更新是MongoDB(4.2版(中的一项非常新的功能,我们正在Realm函数中支持MQL,最高可达MongoDB 4.4。我们预计这将在不久的将来发布。

最新更新