Add $filter operator to filter subdocument values

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.2.0
    • Component/s: Querying
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 }
             ]
            }
      

              Assignee:
              Unassigned
              Reporter:
              Artem
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: