i have many number of documents in collection want save same data changing 1 field i.e. "date" (which current time) repeatedly in mongo database.so how can in mongodb.
you can use $set
operator update 1 filed of document. don't need rewrite whole document:
collection.update({"_id": docid}, {$set: {"date": somedate }})
consider use $currentdate
operator if want set field current date value:
collection.update({"_id": docid}, {$currentdate: {"date": true }}) // or collection.update({"_id": docid}, {$currentdate: {"date": { "$type": "timestamp" }}})
Comments
Post a Comment