Mongodb (mongoose) condition check is not work as I expect
I have the following BSON : [ { arr: [ { age: 24 }, { age: 55 } ] }, { arr: [ { age: 12 }, { age: 14 }, { age: 17 } ] }, { arr: […
I have the following BSON : [ { arr: [ { age: 24 }, { age: 55 } ] }, { arr: [ { age: 12 }, { age: 14 }, { age: 17 } ] }, { arr: […
I need a query to find any documents exists in users collection which has groups._id which is not present in _id of groups collection users collection - docs { "_id": ObjectId("65c35a039773c8593fc45ddb"), "email": "email", "name": "name", "groups": [ { "_id": ObjectId("65c1b7716f130b7c4190104a"),…
{ _id: ObjectId("65bc98f235375d1d97621e06"), name: 'Aspirin', type: 'Pain Relief', forms: [ { formType: 'TabletsData', strength: '100mg', dosageInstructions: [ { time: 'Morning', instructions: [ { step: 1, text: 'Take 1 tablet with breakfast.', _id: ObjectId("65bc98f235375d1d97621e09") }, { step: 2, text: 'Drink a…
time: { $currentDate: { $type: "timestamp" } } }); It's not working for insert() can you help me, anyone?
I'm learning back end development and need some help in mongodb, axios my project is a simple todo app which stores the created tasks in a mongoDB database. link of repository is here My problem is when I create a…
I have used find to fetch record which was giving me a mongoose record, then I used toJson() to convert to object so I can modify the fields. body = req.body; const data = model.find({target: body.target}); I am getting mongoose…
I have a mongodb query and already created all required indices. But query still scanning all the documents in the collection. Following is the query: [ { "$group": { "driverStatuses": { "$addToSet": "$driverStatus" }, "batchAddedAt": { "$first": "$batchAddedAt" }, "cityId":…
I have a collection of documents that each contain arrays. the output i want is the unwinded array elements filtered down by a certain criteria. i can do this by doing: db.collection.aggregate([ { $unwind: "$myArrayField" }, { $match: { "myArrayField.myCriteriaField":…
I have two models called session and unreadcount. I need to get that particular session count from another table. below are my two Mongodb models. var UnreadCountSchema = new mongoose.Schema({ userId: { type: String, required: true }, sessionId: { type:…
I am working on an endpoint with nodejs/express and mongoose. The endpoint should return only the found ID like this: { "id": 3000, "group": 3, "title": "", "start_time": "2023-07-31T11:00:00.000Z", "end_time": "2023-07-31T20:00:00.000Z", "category": "green" } However, when I tested (localhost:3000/api/one/3000) it…