-
Type: Question
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
I am not completely certain, but I believe at present it is not possible to return only selected document(s) from within an embedded array. For instance;
document A {
user_name: example_user,
remaining_tokens: 40,
assignees_array[
,
{UUID: 1F0, next_checkin_time: <some_unix_time>, expires: <some_unix_time>}, ... ]
}
If my program has knowledge of the UUID, and wishes to see only the sub-document (e.g. If we queried for UUID 7 and then read the next_checkin_time and some other fields).
db.my_collection.find("assignees_array.UUID":"1F0"} =>
{UUID: 1F0, next_checkin_time: <some_unix_time>, expires: <some_unix_time>}At present I do not know of a way that it is possible to achieve this, as it returns the entire parent document and all array elements (losing some of the benefit of selecting on the basis of the embedded document's UUID), so you have to iterate to find the correct item.
- duplicates
-
SERVER-828 Support for selecting array elements in return specifier (projection)
- Closed