Andrey Kon
Andrey Kon

Reputation: 1149

Query array elements instead of documents

Can I query elements of arrays which are inside documents instead of querying whole documents? I. e. I want to receive array elements, not documents. E. g., I have this:

{
  blog: 'blog1',
  comments:
  [{user: 'Alice', text: 'bla-bla-bla'}, {user: 'Sarah', text: 'bla-bla-bla'}, ...]
},
{
  blog: 'blog2',
  comments:
  [{user: 'John', text: 'bla-bla-bla'}, {user: 'Alice', text: 'bla-bla-bla'}, ...]
}

How can I get a list of comments written by Alice?

Upvotes: 0

Views: 107

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33145

You can't do this yet. See https://jira.mongodb.org/browse/SERVER-828

Upvotes: 2

Related Questions