Registry / database / mongodb-changelog

mongodb-changelog

JSON →
library3.0.1jsnpmunverified

A Liquibase-inspired MongoDB migration tool for Node.js, version 3.0.1. It provides a simple way to apply sequential changes to MongoDB with tracking in a 'databasechangelog' collection. Unlike other migration libraries, it focuses on synchronous processing of change sets and automatic detection of modifications via md5 checksums. Suitable for Node >=10, with basic async/await support. Release cadence is low, maintained sporadically.

npm install mongodb-changelog
INSTALL
IMPORT
SIG · MONGODB-CHANGELOG
M
mongodb-changelog
databasejavascriptv3.0.1
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 export (changelog function)
const changelog = require('mongodb-changelog'); changelog(config, tasks);
import changelog from 'mongodb-changelog';
This package uses CommonJS and doesn't export ESM. Using ES import syntax will fail.
Promise usage
const changelog = require('mongodb-changelog'); changelog(config, tasks).then(() => {...});
The function returns a Promise, so you can use .then() or async/await.
TypeScript usage
// @ts-ignore const changelog = require('mongodb-changelog');
import changelog from 'mongodb-changelog';
No TypeScript definitions bundled. Use require and optionally declare module.

Imports the changelog function, configures a MongoDB connection, defines two migration tasks, and applies them sequentially.

const changelog = require('mongodb-changelog'); const config = { mongoUrl: 'mongodb://localhost:27017/test' }; const tasks = [ { name: 'createUsersCollection', operation: (db) => db.createCollection('users') }, { name: 'addAdminUser', operation: (db) => db.collection('users').insertOne({ username: 'admin', role: 'admin' }) } ]; changelog(config, tasks) .then(() => console.log('Migrations applied successfully')) .catch(err => console.error('Migration failed:', err));
Debug
Known issues
gotchaPackage uses synchronous processing of tasks. If a task operation is async (e.g., returns a Promise), it must be properly handled; the library expects the operation to return a Promise or value.
fix
Ensure your 'operation' function returns a Promise if it performs async work. For sync operations, simply return a value.
affects: >=1.0.0
breakingVersion 3.0.0+ requires Node.js >=10. Older versions will not work.
fix
Upgrade Node.js to >=10 or pin to an older version of the package (e.g., 2.x).
affects: <3.0.0
gotchaThe tasks are executed in order, but if any task fails, subsequent tasks are not executed. There is no rollback mechanism.
fix
Plan your tasks to be idempotent and handle errors within each operation if needed.
affects: >=1.0.0
deprecatedThe package uses 'databasechangelog' collection name (hardcoded). No configuration option to change it.
fix
No fix available; be aware of the hardcoded collection name.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: changelog is not a function
Using ES module import syntax with a CommonJS module.
fix
Use require('mongodb-changelog') instead of import.
MongoError: Authentication failed
mongodb-changelog uses native MongoDB driver; connection string must include auth credentials if needed.
fix
Set mongoUrl with credentials, e.g., mongodb://user:pass@localhost:27017/test.
Cannot find module 'mongodb-changelog'
Package not installed or not in node_modules.
fix
Run 'npm install mongodb-changelog' in your project directory.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mongodb-changelog — npm install mongodb-changelog · libregistry