skip to Main Content

MongoDB – Query same collection twice

I have a posts collection and I want to return the latest posts and featured posts with 1 query. post document sample { "title":"Hello World", "author":"Bob Paul", "featured":True, "published":True, "created_at":"2019-01-15 10:27:16.354Z" } This is what I want returned: { "latest":…

VIEW QUESTION

Mongodb – Get count of documents matching different conditions

I have collection: bookSchema as: [ { _id: ObjectId("637d05dc32428ed75ea08d09"), book_details: { book_name: "random123", book_auth: "Amber" } }, { _id: ObjectId("637d0673ce0f17f6c473dee2"), book_details: { book_name: "random321", book_auth: "Amber" } }, { _id: ObjectId("637d069a3d597c8458ebe4ec"), book_details: { book_name: "random676", book_auth: "Amber" } }, {…

VIEW QUESTION

Mongodb – Filter nested objects

I have a collection of docs like {'id':1, 'score': 1, created_at: ISODate(...)} {'id':1, 'score': 2, created_at: ISODate(...)} {'id':2, 'score': 1, created_at: ISODate(...)} {'id':2, 'score': 20, created_at: ISODate(...)} etc. Does anyone know how to find docs that were created within the…

VIEW QUESTION
Back To Top
Search