Registry / database / data-elevator-mongodb

data-elevator-mongodb

JSON →
library6.0.2jsnpmunverified

A flexible MongoDB-based migration utility for managing database schema and data migrations. Current stable version is 6.0.2, supporting Node >=18.0.0. It stores migration state in MongoDB, enabling coordination across multiple instances or developers. Key differentiator: uses MongoDB as the state store rather than local files, ideal for shared databases in multi-instance deployments. Release cadence is periodic, with breaking changes between major versions. Alternatives include db-migrate and migrate-mongo, but data-elevator-mongodb offers a more opinionated, project-structure-based workflow.

npm install data-elevator-mongodb
INSTALL
IMPORT
SIG · DATA-ELEVATOR-MONG
D
data-elevator-mongodb
databasejavascriptv6.0.2
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.

construct
import { construct } from 'data-elevator-mongodb'
const construct = require('data-elevator-mongodb').construct
Package is ESM-only; use named import for the construct function.
MongoClientHelpers
import { MongoClientHelpers } from 'data-elevator-mongodb/lib/helpers/mongo-client-helpers'
const MongoClientHelpers = require('data-elevator-mongodb').MongoClientHelpers
MongoClientHelpers is exported from a subpath; named import from the helpers module.
Config
import type { Config } from 'data-elevator-mongodb'
import { Config } from 'data-elevator-mongodb'
Config is a TypeScript interface; use type-only import to avoid runtime errors.

Installs the package, initializes the project structure with 'construct', adds a migration floor, then runs various 'move' commands to apply migrations.

npm install data-elevator-mongodb node ./node_modules/data-elevator-mongodb construct node ./data-elevator/elevator add "add phone number to users" # Edit ./data-elevator/floors/xxx.js node ./data-elevator/elevator move top node ./data-elevator/elevator move ground node ./data-elevator/elevator move 2 node ./data-elevator/elevator move up 2 node ./data-elevator/elevator move down 3
Debug
Known issues
breakingIn v6, the package requires Node >=18.0.0. Older Node versions (16.x) will throw an error during installation.
fix
Upgrade to Node 18+ or stay on v5.x if stuck on older Node.
affects: >=6.0.0
deprecatedThe MongoClientHelpers class is deprecated as of v6. Use direct mongodb driver methods with the connection from levelControllerConfig.
fix
Migrate to using 'levelControllerConfig.connectionUrl' and 'mongodb' driver directly.
affects: >=6.0.0
gotchaIf you use CommonJS (require), you must import the subpath helpers like 'data-elevator-mongodb/lib/helpers/mongo-client-helpers' because the main entry is ESM-only.
fix
Use ESM imports or require the specific subpath: const MongoClientHelpers = require('data-elevator-mongodb/lib/helpers/mongo-client-helpers');
affects: >=6.0.0
gotchaThe 'construct' command creates a './data-elevator' directory in the current working directory, not in the project root if run from a different path.
fix
Run the construct command from the project root directory.
affects: >=0.0.0
brokenThe module does not handle MongoDB connection pooling; each migration floor opens a new connection, which may cause performance issues.
fix
Implement custom connection pooling by passing a shared MongoDB client in the config.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'data-elevator-mongodb/lib/helpers/mongo-client-helpers'
Incorrect import path or missing dependency installation.
fix
Ensure the package is installed and use the correct path: require('data-elevator-mongodb/lib/helpers/mongo-client-helpers')
TypeError: data_elevator.construct is not a function
Using CommonJS require on an ESM-only package.
fix
Use ESM import: import { construct } from 'data-elevator-mongodb'
Error: Cannot find module 'async'
The 'async' package is used in migration examples but is not listed as a dependency.
fix
Install async: npm install async
MongoError: Authentication failed
Incorrect connectionUrl or missing credentials in levelControllerConfig.
fix
Check connectionUrl format (e.g., mongodb://user:pass@host:port/db) and ensure the database user has proper permissions.
Upgrade
Version history
6.0.2latest on npm
Audit
Dependencies
mongodbrequiredRequired for MongoDB connectivity and collection operations
data-elevatorrequiredCore migration framework that this package extends
asyncoptionalUsed in migration examples for asynchronous control flow
Agent activity
7 hits · last 30 days
node
6
Resources
data-elevator-mongodb — npm install data-elevator-mongodb · libregistry