Answer the question
In order to leave comments, you need to log in
What is the best way to update all values in the database?
I have an array of objects. So far they are doing this, but it turns out that I update 1 instance each time, and this is not correct.
const arr = await model.find({})
arr .forEach(async instanse => {
await model.update(
{ _id: instanse._id },
{ $set: {key1: value1, key2: value2}) }
)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question