Le 3 juin 2015 � 19:32, phil@highoctane.be a �crit :


Le 3 juin 2015 17:45, "Christophe Demarey" <christophe.demarey@inria.fr> a �crit :
>
> Hello,
>
> I would like to use set operators defined in mongo but it looks like there is no support for the aggregation framework in the mongo driver.
> Does anyone has information about this?

Search the list as I posted an example before.

ok, I finally found your example :

mongo := Mongo default open.
db := mongo databaseNamed: 'somedb'.

aCommandDict := {  'distinct' -> 'somecollection'. 'key' -> 'XYZ'. 'query' -> nil } asDictionary.

reply := db command: aCommandDict.

(CollectionValidation on: reply) isOK.

distinct :=  reply at: #values.

There is no OO support in the driver for that.

So aggregate can be run as a command with the Mongo driver.
I checked the following code:
Mongo>>command: aDictionary database: aDatabase
| query |
query := MongoQuery new
database: aDatabase;
collection: (MongoMetaCollection name: '$cmd');
where: aDictionary;
yourself.
^self queryOne: query.

I do not understand why a MongoQuery is used there and why it is supposed to return only one element (queryOne)?

Thanks,
Christophe