Here is an example MongoDB collection of articles with embedded comments:
{
_id: 1,
name: "article_1",
comments: [
{ title: 'title_1_1', ... },
{ title: 'title_1_2', ... }
]
}
{
_id: 2,
name: "article_2",
comments: [
{ title: 'title_2_1', ... },
{ title: 'title_2_2', ... },
{ title: 'title_2_3', ... }
]
}
How can I efficiently query for the total count of comments? The result should be 5 for the example above.