Mongo and aggregation framework

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Mongo and aggregation framework

demarey
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?

Thanks,
Christophe
Reply | Threaded
Open this post in threaded view
|

Re: Mongo and aggregation framework

philippeback


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.

There is no OO support in the driver for that.

Phil

>
> Thanks,
> Christophe

Reply | Threaded
Open this post in threaded view
|

Re: Mongo and aggregation framework

demarey

Le 3 juin 2015 à 19:32, [hidden email] a écrit :


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

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Mongo and aggregation framework

philippeback


On Wed, Jun 3, 2015 at 10:50 PM, Christophe Demarey <[hidden email]> wrote:

Le 3 juin 2015 à 19:32, [hidden email] a écrit :


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)?

Because $cmd is a special collection that one uses for issuing such requests. You always have to pass a collection to mongo.

QueryOne is issuing the query.

HTH
Phil
 

Thanks,
Christophe