| Steps To Reproduce: |
> db.projection_test.insert({ "some_field" : "some_value1", "my_array" : [ { "num_field" : 100, "s_field" : "aaa" }, { "num_field" : 100, "s_field" : "bbb" } ] })
|
WriteResult({ "nInserted" : 1 })
|
> db.projection_test.insert({ "some_field" : "some_value2", "my_array" : [ { "num_field" : 500, "s_field" : "aaa" }, { "num_field" : 100, "s_field" : "bbb" } ] })
|
WriteResult({ "nInserted" : 1 })
|
> db.projection_test.insert({ "some_field" : "some_value3", "my_array" : [ { "num_field" : 250, "s_field" : "aaa" }, { "num_field" : 100, "s_field" : "bbb" } ] })
|
WriteResult({ "nInserted" : 1 })
|
>
|
Now, let's run the query with the projection:
> db.projection_test.find({ "my_array.0.num_field": { $lt: 300 } }, {"some_field": 1, "my_array.0.num_field": 1})
|
{ "_id" : ObjectId("53f9e04d7c6631fa3b232bb0"), "some_field" : "some_value1", "my_array" : [ { }, { } ] }
|
{ "_id" : ObjectId("53f9e0617c6631fa3b232bb2"), "some_field" : "some_value3", "my_array" : [ { }, { } ] }
|
>
|
So, the query match on the field of the concretely named array element works, but the projection clearly doesn't. It returns empty objects for the elements "my_array.0".
|