-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 4.2.1
-
Component/s: Aggregation Framework
-
Query Optimization
Aggregation framework has a filter, which filters an array (and returns an array).
I wish there was an equivalent to do a javascript Array.find(), where the filter would return the first match inside of the array
db.test.insert({people: [{name: 'bob', value: 1}, {name: 'fred', value: 2}]}); db.test.aggregate([{$addFields: { person: { $find: { input: '$people', cond: {$eq: ['$$this.name', 'fred']} } }, people: '$$REMOVE' }}]); ##returns {person: {name: 'fred', value: 2}}
- is duplicated by
-
SERVER-44957 Proposal: $find aggregation pipeline operator
- Closed