Re: difference between aggregate ($match) and find, in MongoDB?

2,772 views
Skip to first unread message

Morgan Cheng

unread,
May 14, 2013, 8:36:47 PM5/14/13
to mongod...@googlegroups.com
With aggregate + $match, you get a big monolithic BSON containing all matching documents.

With find, you get a cursor to all matching documents. Then you can get each document one by one. 


On Wednesday, May 15, 2013 4:41:24 AM UTC+8, Hassan Abbas wrote:

What is the difference between the $match operator used inside the aggregate function and the regular find in Mongodb?

Why does not the find function allow renaming the field names like the aggregate function? 

e.g. In aggregate we can pass the following string:

 { "$project" : { "OrderNumber" : "$PurchaseOrder.OrderNumber" , "ShipDate" : "$PurchaseOrder.ShipDate"}} 

Whereas, find does not allow this.

Why does not the aggregate output return as a DBCursor or a List? and also why can't we get a count of the documents that are returned?

Thank you.

Sam Millman

unread,
May 16, 2013, 10:29:27 AM5/16/13
to mongod...@googlegroups.com
d=db.g.aggregate();
console.log('The length of returned results were: '+d.results.length);


On 16 May 2013 09:06, Nirmalkumar Seshachalam <nirmalkumar...@gmail.com> wrote:
" why can't we get a count of the documents that are returned"

--> Any answers for this?. I am also having a need to find count on the output of aggregation function.

On Wednesday, May 15, 2013 2:11:24 AM UTC+5:30, Hassan Abbas wrote:

What is the difference between the $match operator used inside the aggregate function and the regular find in Mongodb?

Why does not the find function allow renaming the field names like the aggregate function? 

e.g. In aggregate we can pass the following string:

 { "$project" : { "OrderNumber" : "$PurchaseOrder.OrderNumber" , "ShipDate" : "$PurchaseOrder.ShipDate"}} 

Whereas, find does not allow this.

Why does not the aggregate output return as a DBCursor or a List? and also why can't we get a count of the documents that are returned?

Thank you.

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages