get rank in mongodb with date range

get rank in mongodb with date range Problem Description: I have following stat data stored daily for users. { "_id": { "$oid": "638df4e42332386e0e06d322" }, "appointment_count": 1, "item_id": 2, "item_type": "user", "company_id": 5, "created_date": "2022-12-05", "customer_count": 1, "lead_count": 1, "door_knocks": 10 } { "_id": { "$oid": "638f59a9bf33442a57c3aa99" }, "lead_count": 2, "item_id": 2, "item_type": "user", "company_id": 5, … Read more

MongoDB Aggregate keep results

MongoDB Aggregate keep results Problem Description: Is there a way to keep results from a match under a new field, and under another new field some computed value? I’m trying to extract a set of genres from a collection of movies, and also keep original results… Document example: { "_id": "62e97ba6ec445b864fc3bc39", "id": 19913, "genres": [ … Read more

How to convert null to string in aggregation?

How to convert null to string in aggregation? Problem Description: My collection Looks like this: [ { "_id": { "$oid": "638ecf5247cf747bdd862bfb" }, "title": "This is title one" }, { "_id": { "$oid": "638ecf5247cf747bdd862bfb" }, "title": null }, { "_id": { "$oid": "638ecf5247cf747bdd862bfb" }, "title": "This is title three" } ] But I want to convert … Read more

Mongodb: Push element in multiple nested array with condition

Mongodb: Push element in multiple nested array with condition Problem Description: How can I push value into multiple nested array with specific conditions? I have a document like this [ { "_id": "class_a", "students": [ { "_id": "1a", "name": "John", "grades": [] }, { "_id": "1b", "name": "Katie", "grades": [] }, { "_id": "1c", "name": … Read more

Mongodb: Push element in multiple nested array with condition

Mongodb: Push element in multiple nested array with condition Problem Description: How can I push value into multiple nested array with specific conditions? I have a document like this [ { "_id": "class_a", "students": [ { "_id": "1a", "name": "John", "grades": [] }, { "_id": "1b", "name": "Katie", "grades": [] }, { "_id": "1c", "name": … Read more

How to get a field from another collection and replace with null if not found?

How to get a field from another collection and replace with null if not found? Problem Description: I have following shcemas: employeeSchema: { _id: ObjectId isActive: Boolean } careerSchema: { employeeId: ObjectId // points to the _id from employeeSchema isCurrentlyWorking: Boolean position: String // designation } I want to find the employees that have field … Read more

How to get a field from another collection and replace with null if not found?

How to get a field from another collection and replace with null if not found? Problem Description: I have following shcemas: employeeSchema: { _id: ObjectId isActive: Boolean } careerSchema: { employeeId: ObjectId // points to the _id from employeeSchema isCurrentlyWorking: Boolean position: String // designation } I want to find the employees that have field … Read more

How to get a field from another collection and replace with null if not found?

How to get a field from another collection and replace with null if not found? Problem Description: I have following shcemas: employeeSchema: { _id: ObjectId isActive: Boolean } careerSchema: { employeeId: ObjectId // points to the _id from employeeSchema isCurrentlyWorking: Boolean position: String // designation } I want to find the employees that have field … Read more

Trying to connect to my Atlas cluster with node.js driver but get "TypeError: client.close is not a function" instead

Trying to connect to my Atlas cluster with node.js driver but get "TypeError: client.close is not a function" instead Problem Description: I’m a newbie on stackoverflow. I’m beginning with mongodb and node.js, following step-by-step tutorials from W3S. I succeeded in connecting to my cluster with mongosh client and performed basic CRUD operations and queries. So … Read more

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject