Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2720

Aggregation on contextual objects

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Currently, aggregation is only available on the collection, and query has to be added manually:

      selector = Band.where(name: "Depeche Mode").query.selector
      Band.collection.aggregate([{"$match"=> selector}, ...])
      

      With this PR, #aggregation will be available on queries and will take selector into account:

      Band.where(name: "Depeche Mode").aggregate({"$sort" => { "likes" => -1}})
      

      (Having to write aggregate pipeline manually isn't that awesome though, I might try to implement a nicer DSL for that later.)

            Assignee:
            Unassigned Unassigned
            Reporter:
            goshakkk goshakkk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: