Support $sortByExpr aggregation pipeline stage

XMLWordPrintableJSON

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

      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 - Query Team (Inactive)
            Reporter:
            Adinoyi Omuya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: