Mongo DB: Update data using `.forEach()`
db.getCollection("posts")
.find({})
.forEach((item) => {
const newValues = item.resources
? item.resources.map((label) => ({ label }))
: [];
item.resources = newValues;
db.posts.save(item);
});
Task: Convert an array o...
codedrops.hashnode.dev1 min read