MongoDB update using limit and skip
Clash Royale CLAN TAG#URR8PPP
MongoDB update using limit and skip
In Mongoose, I would need to do the following in the quickest possible way:
what do you suggest?
Yes, I update them with the same value
– Ehsan
Aug 13 at 9:18
1 Answer
1
you can get records and then get id's of all the records into one array and then
update them using $in
$in
async function someAsyncFunction()
let foundData= await collection.find(query).skip().limit();
let IDs=;
foundData.forEach(element=>
IDs.push(element._id);
);
return Collection.update(
_id: $in: IDs,
$set: "fieldToUpdate": "value",
multi: true
);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
do you want to update a field in all the found records with same value?
– Yogesh.Kathayat
Aug 13 at 9:14