Wednesday, 11 September 2013

Nested subdocument array embed or link?

Nested subdocument array embed or link?

So, my question is the same as MongoDB relationships: embed or reference?
however I was wondering if one should embed or link with adding another
level of nesting, like answers, into the schema.
Like so:
Question
body: "This is my question"
Comments: [
comment: {
_id: ObjectId
body: "This is a comment on the question"
}
]
Answers: [
answer: {
_id: ObjectId
body: "This is an answer"
Comments: [
comment: {
_id: ObjectId
body: "This is a comment on this answer"
}
]
}
]
My schema doesn't actually have anything to do with questions, answers, or
comments but the schema structure is identical in terms of the nesting and
types of queries such as editing and sorting that one would do in this
case.
Also, I realized that it's not possible to do use positional notation
beyond a single level of array nesting. So answers.$.comments.$.body
wouldn't be possible...
https://jira.mongodb.org/browse/SERVER-831?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab

No comments:

Post a Comment