Details
-
New Feature
-
Status: Backlog
-
Minor - P4
-
Resolution: Unresolved
-
4.2.1
-
None
Description
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}} |
Attachments
Issue Links
- is duplicated by
-
SERVER-44957 Proposal: $find aggregation pipeline operator
-
- Closed
-