[SERVER-36927] Projection operator to return all and only array elements which matched filter in queries. Created: 29/Aug/18 Updated: 04/Nov/18 Resolved: 01/Oct/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Joe Langeway at Live Earth | Assignee: | Nick Brewer |
| Resolution: | Won't Fix | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
There are a dozen issues spanning years that ask for this feature and all are incorrectly closed saying that $elemMatch or $ projection operators do this. That is wrong. Examples: Many use cases require ALL the matching elements from an array field, not just the first. I have a collection with documents that look like this: {{{}}
and I'd like to do a query like: {{collection.find({entityId: {$in: [1, 7]}, 'events.eventId': {$in: [3, 4, 5, 9], {entityId: 1, 'events.$$': 1})}} which I would expect to return: {{{}} This can be done with an aggregation, but that is not an acceptable work around for many use cases. Is there ever going to be such a feature for "find"s?
|
| Comments |
| Comment by Nick Brewer [ 01/Oct/18 ] |
|
jlangewayle Since there's been no activity on this ticket in some time, I'm going to close it. Let us know if you have any questions. -Nick |
| Comment by Nick Brewer [ 30/Aug/18 ] |
|
jlangewayle As you've noted, aggregation is the way to accomplish this - there's currently not any plans to implement similar functionality in find. What use case you're hitting where aggregation isn't possible? Thanks, |
| Comment by Joe Langeway at Live Earth [ 29/Aug/18 ] |
|
I apologize, the wysiwyg editor mucked up the bits that were supposed to be preformatted. I expect most readers will still get the point. |