
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
mongo-iterator
Advanced tools
A small utility for efficiently iterating through MongoDb collections.
npm i --save mongo-iterator
This library exposes a single class MongoIterator. The constructor takes a Mongo cursor and callback. The callback is executed with a batch of documents from the cursor. Conceptually it functions as a forEach loop.
Under the hood a MongoIterator object gathers a single bach from Mongo before invoking the callback. This means it avoids unecessary network requests. It is useful for iterating over large collections for ETL jobs or for updating documents en masse.
This library is in a work in progress. Breaking changes are inbound. YMMV.
Tested with:
import { MongoClient } from "mongodb";
import { MongoIterator } from "./src";
async function main(): Promise<void> {
const client = new MongoClient(...);
await client.connect();
const cursor = client
.db('')
.collection('')
.find({})
.sort({_id: 1})
.batchSize(2000);
const iterator = new MongoIterator(cursor, async batch => {
// do something with the batch
});
await iterator.run();
// log/inspect iterator.getMetrics();
}
Just read the code. It's short.
pause/resume methods.FAQs
A small utility for efficiently iterating through MongoDb collections
We found that mongo-iterator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.