umzug-mongo
v1.2.1
Published
Umzug adapter for mongo migrations.
Downloads
72
Maintainers
Readme
umzug-mongo
Umzug adapter for mongo migrations.
Usage
Simply pass in your promise-compliant mongodb-core database or collection object.
var Umzug = require('umzug');
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/mydatabase').then(function (db) {
var umzug = new Umzug({
storage: 'umzug-mongo',
storageOptions: {
connection: db,
collectionName: 'mymigrations', // defaults to 'migrations'
},
});
return umzug.up();
});
or
var Umzug = require('umzug');
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/mydatabase').then(function (db) {
var migrations = db.collection('migrations');
var umzug = new Umzug({
storage: 'umzug-mongo',
storageOptions: {
collection: migrations,
},
migrations: {
params: [db]
},
});
return umzug.up();
});