Mongo PHP Driver and new aggregation framework operation count()

268 views
Skip to first unread message

mongo-php

unread,
Apr 2, 2012, 6:15:41 AM4/2/12
to mongod...@googlegroups.com
Hey Group,

is there a special method to count the results of the following db.runCommand
(I transfered this to the mongo php driver)

db.runCommand( { aggregate: "cities", pipeline: [
{$match : { "days" : { $exists: true} }},
{$limit : 10000 },
{$project : {
name : 1,
sum : { $add:["$days.4", "$days.4","$days.9"] }
}},
{ $sort : { sum : -1}},
}]);

I declared a limit but often the limit is under the given limit.
I want to do some pagination with the data and need the results count.

Thanks in advance ....



 

Brendan W. McAdams

unread,
Apr 2, 2012, 3:51:17 PM4/2/12
to mongod...@googlegroups.com
The results of this job will be returned in the "result" field of the return doc as an array. Simply count the size of that array client side.
Reply all
Reply to author
Forward
0 new messages