skip to Main Content

Mongodb – filter array based on ObjectId

So I have 2 arrays here, let say const users = [{_id:ObjectId("6274fb5b82bcc9b2ccc0a361"), name:p1, age:10}, {_id:ObjectId("6274fbc382bcc9b2ccc0a362"), name:p2, age:15}, {_id:ObjectId("6277a3d5b66c061096222bbd")}, name:p3, age:20]; const filterArray = [ObjectId("6274fbc382bcc9b2ccc0a362"),ObjectId("6277a3d5b66c061096222bbd")]; I want to filter result based on matching ObjectId, here's what I'm trying to do const…

VIEW QUESTION

Value not saving in mongodb

const serverS = await server.findOne({ guildID: message.guild.id }); serverS.settings[1]["links"] = true; serverS.save() The code I use ^^^^ So when it saves the changes I check the database using MongoDB compass I don't see the change appearing in the array object…

VIEW QUESTION

extract subdocument in mongoDB

I am new to MongoDB and I'm struggling in extract a subdocument from a document. In my case, I have the following schema: [ { user_id: "u1", subscriptions: [ { "tier": "Basic", "requests": [ { "name": "aaaa" }, { "name":…

VIEW QUESTION
Back To Top
Search