Created
December 11, 2012 21:05
-
-
Save mrmarcondes/4262138 to your computer and use it in GitHub Desktop.
10gen: M101 MongoDB for Developers - Final - question 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.messages.aggregate([ | |
{$project: {"_id": 0, | |
"headers.From": 1, | |
"headers.To": 1 | |
}}, | |
{$unwind: "$headers.To"}, | |
{$group: { | |
"_id": {from: "$headers.From", | |
to: "$headers.To"}, | |
sum: {"$sum": 1} | |
}}, | |
{$sort: {"sum": 1}} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am new to MongoDb , I have to store Post and its comments in MongoDb. Please tell me is structure given below will work good.
{"POST_TITLE":"Title", "POST_DESCRIPTION":"Description", "COMMENTS":[ {COMMENT1}, {COMMENT2} ] }
Thanks in advance.