MongoDB relationships: embed or reference?

后端 未结 11 2377
夕颜
夕颜 2020-11-21 05:34

I\'m new to MongoDB--coming from a relational database background. I want to design a question structure with some comments, but I don\'t know which relationship to use for

11条回答
  •  囚心锁ツ
    2020-11-21 06:02

    I know this is quite old but if you are looking for the answer to the OP's question on how to return only specified comment, you can use the $ (query) operator like this:

    db.question.update({'comments.content': 'xxx'}, {'comments.$': true})
    

提交回复
热议问题