On Wed, Sep 12, 2012 at 12:08 PM, Sean Corfield <
seanco...@gmail.com> wrote:
> Has anyone had a look at the aggregation stuff yet? Any thoughts on
> what CongoMongo might need to add to provide reasonable support for
> this?
To answer my own question, it looks like we just need one new
function, aggregate, that looks something like this:
(aggregate :coll op & ops)
;; e.g., (aggregate :foo {:$match {:type "airfare"}} {:$project
{:department 1, :amount 1}} {:$group {:_id "$department" :average
{:$avg "$amount"}}})
(based on
http://www.mongodb.org/display/DOCS/Using+The+Aggregation+Framework+with+The+Java+Driver
)
It would call (.aggregate (get-coll :coll) (coerce op [from :mongo])
(into-array DBObject (map #(coerce % [from :mongo]) ops)))
That would return an AggregationOutput on which we'd call
.getCommandResult and then coerce that [:mongo to] to get the result.
I'll get a version of that knocked out today or tomorrow so folks can
play with it in a snapshot...