Many to many update in MongoDB without transactions

前端 未结 3 930
死守一世寂寞
死守一世寂寞 2021-02-14 20:08

I have two collections with a many-to-many relationship. I want to store an array of linked ObjectIds in both documents so that I can take Document A and retrieve all linked Doc

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-14 20:44

    Why don't you create a dedicated collection holding the relations between A and B as dedicated rows/documents as one would do it in a RDBMS. You can modify the relation table with one operation which is of course atomic.

提交回复
热议问题