Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 }
                );
            });```
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongodb #mongoose #update #convert #string #object
ADD COMMENT
Topic
Name
1+3 =