mongodb mongoose update convert string to object code example
Example: mongodb mongoose update convert string to object
const media = await Media.find({});
media.forEach(async (item) => {
const update = await Media.findOneAndUpdate(
{ _id: item._id },
{ user: mongoose.Types.ObjectId(item.user) },
{ upsert: true }
);
});```