Closed durran closed 11 years ago
I will be working on it... any considerations?
This one will be a bit more tricky since it's a full blown DSL around it. I'm open to suggestions but before you go doing any amount of significant work on this one please run the ideas by me first. :)
I will also think about this some more this weekend and come up with some ideas for you as well. Appreciate you spearheading the aggregation framework efforts. :)
Just trying to improve my ruby skills and mongoid/moped/origin are really great projects to work on.... well designed... both code and tests.....
The aggregate operation is always executed over a collection, so I am not sure where we should start the DSL.
If we include something like Origin:Aggregatable on Origin::Queryable the user will be able to mix query selectors with aggregation operators, this could be a good idea if we consider that the selector will become a $match operator. But the user will be able to mix things and may end up with something not readable.
I am thinking on something like this for the dsl:
criteria = Criteria.new
criteria.project(author : true, tags : true)
.unwind(:tags)
.group(_id: { tags: true }, authors: { addToSet: :author})
Which will be translated to:
{ $project : {
author : 1,
tags : 1,
} },
{ $unwind : "$tags" },
{ $group : {
_id : { tags : 1 },
authors : { $addToSet : "$author" }
} }
@durran Please, give your considerations or your ideas about this.
Any update about this ?
Finished on master.
See docs, need to flush out API in Origin.
http://www.mongodb.org/display/DOCS/Aggregation+Framework http://www.mongodb.org/display/DOCS/Aggregation+Framework+-+Expression+Reference