【问题标题】:Can MongoDB potentially return the same document to two async calls of findOneAndUpdate({ field: { exists: false }})MongoDB 能否将同一个文档返回到 findOneAndUpdate({ field: { exists: false }}) 的两个异步调用?
【发布时间】:2021-01-05 18:34:59
【问题描述】:

目标是永远不要让函数的两个异步调用返回相同的文档,其中发送的字段不存在。

我希望一个调用收到的文档不能被另一个 findOneAndUpdate 调用返回。

public getNextOpenDocument(data) {
  return this.collection.findOneAndUpdate(
    { data: { $exists: false } },
    {
      $set: {
        data: data
      }
    })
}

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    在具有快照读取问题的事务中,我预计不会。

    否则,我希望是的。

    【讨论】:

      猜你喜欢
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 2021-11-16
      • 2016-10-15
      • 1970-01-01
      • 2023-03-05
      相关资源
      最近更新 更多