Re: Re: printing data other than in mongo using aggregation frame work

From: Amar Singh <amar09108@xxxxxxxxx>
To: mongodb-user@xxxxxxxxxxxxxxxx
Date: Tue, 26 Apr 2016 17:11:01 +0530
Why ads?
By default $group gives only the the grouped field value. You can use
$first, $last, $push for getting other fields.

One example could be like this

db.test.aggregation({"$project": "status":1,"cost":1 },{"$group":{_id:
"name","cost"},"status":{"$first":"$status"}})

You can use other operators as well.


*Amar Singh*

On Mon, Apr 25, 2016 at 12:48 PM, Rhys Campbell <
rhys.james.campbell@xxxxxxxxx> wrote:

Provide a few sample documents.

--
You received this message because you are subscribed to the Google Groups
"mongodb-user"
group.

For other MongoDB technical support options, see:
https://docs.mongodb.org/manual/support/
---
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+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/71cbb709-588b-4d29-b31f-f69168a26110%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/71cbb709-588b-4d29-b31f-f69168a26110%40googlegroups.com?utm_medium=email&utm_source=footer>
.

For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
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+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAA1QGCCbSAuUrMcfDRmbU7tHuW-pd8YY%2B3s%2BRWzQ9BZXf%3DU_5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?