Each document in my collection has a status
field that needs to be updated periodically with an async api call that fetches the document's current status by its id.
For example:
db.items.update({}, { $set: { status: getStatusById(id?) } }, handleResult);
I cannot just select all ids at once as my process runs out of memory if I do that. There are over 6 million documents in the collection.
If there is no shortcut, another approach would be to step through the database 100 at a time but I'm not sure if that's the best approach here.
I am looking for something analogous to docs.map(getStatusById)
in JS only with a mongodb collection.
getStatusById
makes an api call to a 3rd party resource -- I need to take results from that and add to doc.