Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-47202

Support $sortByExpr aggregation pipeline stage

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query

      Possible syntax:

      { $sortByExpr: <aggregation expression>  }
      

      Sort by salesAmount ascending:

      db.users.aggregate( [ { $sortByExpr : { $sum: { $multiply: [ "$price", "$quantity" ] } } } ] )
      

      This will allow for what currently requires $addFields + $sort + $project.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            adinoyi.omuya@mongodb.com Adinoyi Omuya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: