Le 3 juin 2015 17:45, "Christophe Demarey" <[hidden email]> 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