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
If I want to edit a specified comment, how do I get its content and its question?
If you had kept track of the number of comments and the index of the comment you wanted to alter, you could use the dot operator (SO example).
You could do f.ex.
db.questions.update(
{
"title": "aaa"
},
{
"comments.0.contents": "new text"
}
)
(as another way to edit the comments inside the question)