A MongoDB specification compliant ObjectID implementation for Node.js, version 1.2.2. Provides a robust alternative to native MongoDB drivers for ObjectID generation and validation. Designed to prevent duplicate IDs under high-frequency generation, a known issue with other implementations. Requires Node >= 12. No added dependencies. Features include customizable machine ID and timestamp generation.
npm install mongo-objectidNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates requiring the module, generating ObjectIds, validation, and custom machine ID.
Use CommonJS `require` instead of `import`.
Avoid using setMachineId() or verify behavior with your version.
Always validate hex strings using `ObjectId.isValid()` before constructing.
Use native MongoDB driver's ObjectId for driver interactions.
Add `const ObjectId = require('mongo-objectid');` at the top.Use `const ObjectId = require('mongo-objectid');`.Switch to CommonJS require or add 'type': 'module' and use dynamic import (not recommended for this package).
Run `npm install mongo-objectid`.
No dependency data recorded yet.