Is it possible in mongodb to use an async function to populate the $set field?
<p>Each document in my collection has a <code>status</code> field that needs to be updated periodically with an async api call that fetches the document's current status by its id.</p>

<p>For example:</p>

<pre><code>db.items.update({}, { $set: { status: getStatusById(id?) } }, handleResult);
</code></pre>

<p>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.</p>

<p>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.</p>

<p>I am looking for something analogous to <code>docs.map(getStatusById)</code> in JS only with a mongodb collection.</p>

<p><code>getStatusById</code> makes an api call to a 3rd party resource -- I need to take results from that and add to doc.</p>