About Ryan
Joined MongoFu 1 year ago
I have nothing to say...Ryan's latest posts
Sort Sub Documents?
Is there a way to sort sub docs in a mongo query? Example(Blog Collection): [code]{ "_id" : ObjectId("4c69d19532f73ad544000001"), "content" : "blah blah blah", "comments" : { {"author": "jim", "content":"comment content 1", "date" : "07-24-1995"}, {"author": "joe", "content":"comment content 2", "date" : "07-24-1996"} {"author": "amy", "content":"comment content 3", "date" : "09-10-1999"} } } { "_id" : ObjectId("4c69d19532f73ad544000002"), "content" : "blah blah blah", "comments" : { {"author": "jim", "content":"comment content 1", "date" : "07-24-1995"}, {"author": "joe", "content":"comment content 2", "date" : "07-24-1996"} {"author": "amy", "content":"comment content 3", "date" : "07-24-1997"} } }[/code] I want to get my blog posts ordered in however way I deiced and then have comments ordered within my blog posts by reverse order by date or any other sorting I want.. Is that not possible with mongoDB?
posted 1 year ago
