Add ability to subquery on an array with similar syntax as querying documents

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Finding the right way to construct a find against elements in an array field can get rather tricky, and the rules become very opaque for those with less experience with MongoDB. 

       

      What I suggest is the ability to essentially nest a subquery into your find/$match, which would treat an array as the new collection. The results of the subquery would replace the array for the rest of the parent find's execution (including what is returned as final result).

      Example:

      db.collection.find({
       firstname: 'Jones',
       lastname: 'Sally',
       addresses: {$arrayFind: {
         state:'TX',
         $sort:{zip:1},
       }}
      )
      

       

      We already have pieces of this in filter, elemmatch, etc, but this feels like it would be a much cleaner interface overall, and allow for some constructs we're still missing. 

       

            Assignee:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            Rod Adams (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: