Registry / database / mdbid
library1.0.0jsnpmunverified

Generates unique string identifiers in Node.js using the same algorithm as MongoDB's ObjectId. Version 1.0.0, stable but unmaintained since 2017. Key differentiators: performant (outperforms bson, mongoid, objectid in benchmarks), simple API with only a few configuration options (machineId, processId, sequence), and no dependencies. Suitable for generating unique IDs without a database, especially for Redis keys.

npm install mdbid
INSTALL
IMPORT
SIG · MDBID
M
mdbid
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import oid from 'mdbid'
const oid = require('mdbid'); // works but CommonJS
Default export is a function that generates an ObjectId string.
machineId
import oid, { machineId } from 'mdbid'
const { machineId } = require('mdbid')
Named export for customizing the machine identifier (3-byte integer).
version
import { version } from 'mdbid'
const version = require('mdbid/version')
Named export for the package version string.

Demonstrates default usage, customization of machine/process/sequence, and accessing the version string.

import oid, { machineId, processId, sequence } from 'mdbid'; // Generate an ObjectId string console.log(oid()); // => '579b64ac12b43732a08531d8' // Customize machine ID (3-byte integer) machineId(1); // Customize process ID (2-byte integer) processId(12345); // Customize initial sequence (3-byte integer) sequence(100); console.log(oid()); // => '...' with custom machine/process/sequence // Access version console.log(oid.version); // => '1.0.0'
Debug
Known issues
deprecatedPackage is no longer maintained; no updates since 2017.
fix
Consider migrating to modern alternatives like 'nanoid' or 'uuid'.
affects: >=1.0.0
gotchaIDs are not cryptographically secure; do not use for security tokens.
fix
Use 'crypto.randomUUID()' or 'uuid/v4' for secure random IDs.
affects: >=0.0.0
gotchaDefault machine ID and process ID may collide across processes if not manually set.
fix
Explicitly set machineId and processId for multi-process environments.
affects: >=0.0.0
breakingNo breaking changes known; package is simple.
fix
No action needed.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'mdbid'
Package not installed or import path incorrect.
fix
Run 'npm install mdbid' and ensure correct import path (e.g., require('mdbid')).
oid is not a function
Using named import instead of default import incorrectly.
fix
Use 'import oid from 'mdbid' or 'const oid = require('mdbid')'.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagemdbid
mdbid — npm install mdbid · libregistry