Hot answers tagged


You can try this. db.testDBA.updateOne( {}, { $currentDate: { modifiedOn:true }, $set: { "item":"anything" } }) I insert a document and update it. It works. If I run this code again, the document will be updated like this


Make it short and simple: db.reportgraphs.aggregate([ { $match:{ d:{$gte:new Date("2001-01-01T00:00:00.000Z"), $lt:new Date()}, bId: ObjectId("5fc151b2c123574e0f835da4") } }, { $set: { yr:{"$year":"$d"}, mt:{"$month":"$d"}, dy:{"$dayOfMonth":"$d"}, h:...


Using a read concern of "majority" does not cause the read operation to be submitted to multiple nodes. When replication.enableMajorityReadConcern is true (default in MongoDB 3.6+) each node will note the most recent write operation that has been acknowledged by a majority of the voting nodes, and keep a snapshot of the data at that point in time. ...


Delete the collection from the DB and then hit he API , it will work. There is no mistake in code.

Only top voted, non community-wiki answers of a minimum length are eligible