Let us have a MongoDB collection which has three docs..
db.collection.find()
{ _id:\'...\', user: \'A\', title: \'Physics\', Bank: \'
It has been updated from the above answers.
please use db.collection.updateOne() instead of db.collection.update().
and also db.collection.createIndexes() instead of db.collection.ensureIndex()
Update:
the methods update() and ensureIndex() has been deprecated from mongodb 2.*, you can see more details in mongo and the path is ./mongodb/lib/collection.js.
For update(), the recommend methods are updateOne, updateMany, or bulkWrite.
For ensureIndex(), the recommend method is createIndexes.