簡體   English   中英

MongoDB Stitch/Realm Function updateMany 出現聚合錯誤

[英]MongoDB Stitch/Realm Function updateMany with aggregation error

我正在嘗試創建一個 function 來解鎖在指定時間之前鎖定的線索。 I tested the updateMany function with an aggregation pipeline in the shell, but when trying to run it from a Realm Function I get an error...

StitchError:更新:修飾符參數必須是 object

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 中的聚合管道? 如果確實如此,我是否犯了錯誤?

嗨 Bernard – 聚合管道中的更新是 MongoDB(帶有 4.2)中的一個相當新的功能,我們正在支持 MQL 到 MongoDB 4.4 在 Realm 函數中。 我們預計這將在不久的將來發布。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM