I am using the below query to change the field name
router.get("/rename", function (req, res) {
var db = req.db;
var collection = db.get('Users');
collection.update({ "Age" : "Male" }, { $rename: { "Age":"Sex" } })
});
The document structure is like
{
"_id": {
"$oid": "55bb3b93324467d01e09c5c0"
},
"Sex":"Male",
"Age": "23",
"userId": "1014366544066103",
"emailId":"someid"
}
Here I am trying to change field name Age to Sex, if the Age field contains Male.
But for some reason it is not changing it
I don't get any errors too