Is there any way to atomically update two collections in MongoDB?

后端 未结 5 1268
轻奢々
轻奢々 2020-12-08 08:45

I have a collection of messages:

{
    messageid: ObjectId
    userid: ObjectId
    message: string
    isread: true|false
}

and a collecti

5条回答
  •  情话喂你
    2020-12-08 08:59

    No, unfortunately this isn't possible. MongoDB only supports atomic operations within the scope of a single document. There's no way to perform a transactional operation across multiple documents, even if they're in the same collection.

提交回复
热议问题