【发布时间】:2013-09-16 04:54:38
【问题描述】:
所以,我的问题与MongoDB relationships: embed or reference? 相同,但我想知道是否应该将另一层嵌套(如答案)嵌入或链接到架构中。
像这样:
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"
}
]
}
]
我的架构实际上与问题、答案或 cmets 没有任何关系,但架构结构在嵌套和查询类型(例如在这种情况下会执行的编辑和排序)方面是相同的。
另外,我意识到除了单层数组嵌套之外,不可能使用位置表示法。所以answers.$.comments.$.body 是不可能的...https://jira.mongodb.org/browse/SERVER-831?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab
【问题讨论】:
标签: arrays node.js mongodb mongoose nested