#Import command
16 messages · Page 1 of 1 (latest)
@ember vortex
here is something I made for you that you can adjust to your liking, let me know if you have question.
This code is very old and 70% of it won’t work at all
Plus you’re fetching Users in a loop too
What doesn’t work, or what doesn’t work as intended?
What im trying to do is get every document with pending points and add it to existing points
So 110011110111’s way of doing it would work but not entirely.
You can fetch all of the documents
Then use findOneAndUpdate in a for of loop
Then do what you’re doing now
Ill try that
Thanks
sorry
@ionic vapor it's still returning an error
CastError: Cast to Number failed for value "[ '$pendingPointCount' ]" (type Array) at path "pointCount"
dont mind the "somthing"
It makes it easier to get stuff
you would need to pass a number inside of $inc not an array, also that for loop won't do anything in terms of promises so use a for of loop
for(const doc of documents) {
await schema.findOneAndUpdate(
{
something
},
{
$inc: {
pountcount: doc.pendingPointCount
},
$set: //set
}
)
}