Category: mongodb

Mongodb client – nodejs : Find methods

Here are some useful query to help you interact with mongo db in node js server 1.To find all documents var requestsColl = myDb.collection(‘requests’); requestsColl.find({}).toArray(function(err, requests) {    if (err)        return callback(err);    return callback(null, requests); }); This will return all document 2. To find all documents with filter var requestsColl = …


Mongodb Nodejs – Replace a value in array item from a nested object

If you have a document like this: {     _id: <value>    comments: [         {              commentId: 1              comment: <value>         },        {              commentId: 2     …