First of all please correct the question's title to appropriate one - it was hard for me to find a short and descriptive title to the question below.
Lets say I have a list of documents like ones below:
[
cdate: { $date: ""2015-09-15T05:53:04.656Z" },
factor1: "aaa",
factor2: "bbb",
extra_info: [
{ host: "ex.com", int_value: 10 },
{ host: "ms.com", int_value: 20 },
{ host: "apple.com", int_value: 5 },
..
]
]
extra_info
array size varies. I need to get all documents having factor1="something", factor2="something else" and one of extra_info's array's host should be equal to "ms.com". The result should be presented as:
[
cdate: { $date: ""2015-09-15T05:53:04.656Z" },
factor1: "something",
factor2: "something else",
host: "ms.com",
int_value: 5
],
[
cdate: { $date: ""2015-09-14T08:17:32.123Z" },
factor1: "something",
factor2: "something else",
host: "ms.com",
int_value: 14
],
...
The question is how to do it?
One ways is that I can get all the documents and then manually filter out extra_info array, leaving only values that I need, but is there any way to stick it in under one query?