I'm trying to change field type to bool among all documents in collection. Here is the code
db.product.find().forEach(function(doc) {
if (doc.checked === "Y") {
doc.checked = true;
} else if (doc.checked === "N") {
doc.checked = false;
}
db.product.save(doc);
});
Mongodb returns no error but doesn't convert fields.
Best Answer
I solved problem using 'db.product.update' instead of 'db.product.save'