Answers for "loop over documents in mongoose"

0

loop over documents in mongoose

const documents = await Model.find({});

documents.forEach(doc => {
	// do something with the document
});
Posted by: Guest on January-24-2022
0

loop over documents in mongoose

for await (const doc of Model.find()) {
  doc.name = "New Name"
  await doc.save();
}
Posted by: Guest on January-24-2022

Code answers related to "loop over documents in mongoose"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language