[SERVER-7224] Add $filter operator to filter subdocument values Created: 02/Oct/12  Updated: 18/Aug/14  Resolved: 18/Aug/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.2.0
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Artem Assignee: Unassigned
Resolution: Duplicate Votes: 1
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-6612 Support projecting multiple array val... Closed
Participants:

 Description   

It's something like as $elemMatch projection works but instead returning the single value it could be return all matches like the follows:

    {
     _id: ObjectId(),
     zipcode: 63109,
     dependents: [
              { name: "john", school: 102, age: 10 },
              { name: "jess", school: 102, age: 11 },
              { name: "jeff", school: 108, age: 15 }
             ]
     }
 
     var projection = { _id: 0, dependents: { $filter: { school: 102 }}};
     db.students.find( { zipcode: 63109 }, projection);
 
     {
       dependents: [
              { name: "john", school: 102, age: 10 },
              { name: "jess", school: 102, age: 11 }
       ]
      }



 Comments   
Comment by Thomas Rueckstiess [ 18/Aug/14 ]

This feature request is asking for an $elemMatch that can "filter" multiple documents, not just the first one, therefore a duplicate of SERVER-6612.

Generated at Thu Feb 08 03:13:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.