skip to Main Content

Mongodb – Count posts of user with default value

Supposed I have a data of [ { "_id": "629eb5ced774223d36a68907", "userId": "629eb22698df1015e980a98f", "posts": [ { "_id": "629eb59ad774223d36a688fa", "title": "titletestz", "body": "bodyz", "createdAt": "2022-06-07T02:19:06.314Z", "updatedAt": "2022-06-07T02:19:06.314Z", "__v": 0 }, { "_id": "629eb59ad774223d36a688fc", "title": "titletestx", "body": "bodyx", "createdAt": "2022-06-07T02:19:06.879Z", "updatedAt": "2022-06-07T02:19:06.879Z", "__v":…

VIEW QUESTION

Need help to MongoDB aggregate $group state

I have a collection of 1000 documents like this: { "_id" : ObjectId("628b63d66a5951db6bb79905"), "index" : 0, "name" : "Aurelia Gonzales", "isActive" : false, "registered" : ISODate("2015-02-11T04:22:39.000+0000"), "age" : 41, "gender" : "female", "eyeColor" : "green", "favoriteFruit" : "banana", "company" :…

VIEW QUESTION
Back To Top
Search