Loop sobre documentos em Mongoose
for await (const doc of Model.find()) {
doc.name = "New Name"
await doc.save();
}
Graceful Grivet
for await (const doc of Model.find()) {
doc.name = "New Name"
await doc.save();
}
const documents = await Model.find({});
documents.forEach(doc => {
// do something with the document
});