A MongoDB driver extension (v1.0.17) that enables consuming MongoDB cursors across multiple Node.js instances, useful in microservice environments. It works by leveraging internal MongoDB wire protocol commands to persist cursor state across restarts or upgrades. Unlike approaches using `limit/skip` (which become slow over large datasets) or range-based queries (costly across indexes), this package directly manipulates cursor internals. It supports mongoose peer dependency ^6 || ^7 || ^8 || ^9 and mongodb driver ^4 || ^5 || ^6 || ^7. Includes TypeScript types. Active development with occasional releases.
npm install mongodb-cross-cursorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates initiating a shared cursor and then resuming it with iteration.
Ensure sharedCursor object has sessionId and cursorId properties.
Upgrade mongodb driver to ^4 || ^5 || ^6 || ^7.
Use initiate() to start a new cursor, then constructor only for resuming.
Use 'for await (const doc of instance.iterate())' instead of 'for (const doc of instance.iterate())'.
Ensure client stays connected until iteration completes.
Use: import MongoCrossCursor from 'mongodb-cross-cursor'; or const MongoCrossCursor = require('mongodb-cross-cursor');Ensure sharedCursor has both sessionId (string) and cursorId (string) fields.
Increase cursor timeout settings via MongoDB driver options; ensure collection exists.
Use iterate() method instead of next(), or ensure you're using v1.x+ where next() may not be available.