У меня есть сборник со статьями. Мне нужна новая коллекция с комментариями. Одна статья может иметь один или несколько комментариев. Комментарии могут иметь ответы.
Как лучше построить его, плоский или встроенный?
1) Плоский
Articles [{
_id: 'abc123'
content: ...
}]
Comments [{
_id: 'comm1'
articleId: 'abc123'
parentCommentId: null
comment: ...
},{
_id: 'comm2'
articleId: 'abc123'
parentCommentId: null
comment: ...
}, {
_id: 'comm3'
articleId: 'abc123'
parentCommentId: 'comm2'
comment: ...
}]
2) Встроенный 1
Articles [{
_id: 'abc123'
content: ...
}]
Comments [{
articleId: 'abc123',
comments: [{
_id: 'comm1'
parentCommentId: null
comment: ...
},{
_id: 'comm2'
parentCommentId: null
comment: ...
}, {
_id: 'comm3'
parentCommentId: 'comm2'
comment: ...
}]
}]
3) Embedded 2
Articles [{
_id: 'abc123'
content: ...
}]
Comments [{
articleId: 'abc123',
comments: [{
_id: 'comm1'
parentCommentId: null
comment: ...
},{
_id: 'comm2'
parentCommentId: null
comment: ...
answers: [{
_id: 'comm3'
comment: ...
}]
}
}]
Спасибо, заранее!