[SERVER-19481] Allow projection on array elements Created: 19/Jul/15 Updated: 20/Jul/15 Resolved: 19/Jul/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | NOVALUE Mitar | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Participants: |
| Description |
|
It would be great if field specification could limit automatically array elements. So that you could do something like: ``` ) And get from: ``` {bar: ['a', 'b', 'c']}``` This result: ``` {bar: 'a'}``` |
| Comments |
| Comment by NOVALUE Mitar [ 19/Jul/15 ] | |
|
Yes, this would only a syntactic sugar. It would also return no singleton array around a document. With $slice you still get an array around. | |
| Comment by Eliot Horowitz (Inactive) [ 19/Jul/15 ] | |
|
You can do this with the $slice operator | |
| Comment by NOVALUE Mitar [ 19/Jul/15 ] | |
|
Oops, it should be
|