Registry / database / mongodb-migrate-nfolds

mongodb-migrate-nfolds

JSON →
library2.0.5jsnpmunverified

Migration framework for MongoDB in Node.js. Version 2.0.5 with no active maintenance (final release). Provides a simple up/down migration pattern using raw MongoDB driver callbacks. Differentiated from mongoose-based tools by using native mongodb driver directly. Designed for older Node.js (0.8.x+) and MongoDB 2.x. CAUTION: depends on deprecated mongodb driver v1.x; not compatible with MongoDB 3+ driver. No npm releases since 2015.

npm install mongodb-migrate-nfolds
INSTALL
IMPORT
SIG · MONGODB-MIGRATE-NF
M
mongodb-migrate-nfolds
databasejavascriptv2.0.5
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.

migrations
Create migration files with exports.up and exports.down as shown in README
module.exports = { up: ... } instead of individual exports
Each migration file exports two functions: up and down. No direct import from package.
CLI
node ./node_modules/mongodb-migrate-nfolds -runmm up
mongodb-migrate-nfolds up (no global install, must use relative path)
Must run from project root with -runmm flag. No programmatic API exposed.
db
function up(db, next) { db.collection('pets').insert({...}, next); }
var mongodb = require('mongodb'); mongodb.Collection(db, 'pets') (deprecated pattern)
Use db.collection() directly for MongoDB 2.x driver. The old mongodb.Collection() syntax is from v1.x.

Creates a migration with up/down functions and runs it via CLI.

// Install // npm install mongodb-migrate-nfolds // Create a migration file ./migrations/0010-add-users.js: exports.up = function(db, next) { db.collection('users').insert({name: 'test'}, next); }; exports.down = function(db, next) { db.collection('users').remove({name: 'test'}, next); }; // Run migrations: // node ./node_modules/mongodb-migrate-nfolds -runmm up
Debug
Known issues
deprecatedPackage uses mongodb driver v1.x (mongodb.Collection() pattern), incompatible with MongoDB driver >=3.0.
fix
Use mongodb-migrate or migrate-mongo for modern MongoDB driver support.
affects: >=2.0.0
gotchaMigration state is stored in a collection named 'migratio' (truncated name due to 30-char limit in MongoDB 2.x? Check actual collection name). This can conflict with other tools.
fix
Use a dedicated database or prefix collection names.
affects: all
gotchaNo programmatic API; must use CLI with -runmm flag and relative path.
fix
Use child_process.spawn or switch to a library with JS API.
affects: all
breakingRequires Node.js >=0.8.x only; may fail on Node >=10 due to removed APIs.
fix
Run on older Node or patch package.json engines.
affects: all
gotchaMigration files are sorted by filename (lexicographic). Ensure numeric prefixes (e.g., 0001, 0002).
fix
Prefix migration filenames with zero-padded numbers.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'mongodb'
Missing mongodb dependency (peer dependency not declared).
fix
npm install mongodb@2
TypeError: db.collection is not a function
Using MongoDB driver v3+ which changed collection API.
fix
Install mongodb@2.x (npm install mongodb@2)
node ./node_modules/mongodb-migrate-nfolds -runmm up: command not found
Not running from the correct directory or path incorrect.
fix
cd to project root and use the exact path: node ./node_modules/mongodb-migrate-nfolds -runmm up
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
mongodb-migrate-nfolds — npm install mongodb-migrate-nfolds · libregistry