mongodbplugin
v1.0.5
Published
Easy Migration is a MongoDB plugin designed to simplify the process of writing and managing migrations in MongoDB databases. It streamlines the development workflow by providing a clear and structured approach to database changes. <br/>
Downloads
1
Readme
Mongo Easy Migration Plugin
Easy Migration is a MongoDB plugin designed to simplify the process of writing and managing migrations in MongoDB databases. It streamlines the development workflow by providing a clear and structured approach to database changes.
Features
Setup
install library from npm using
npm i mongodbpluginUsage
What you need is your
const processMigration = require("mongodbplugin");
let mongoDB_URI = process.env.DB_URL
let primaryCollection = require("./models/primaryCollection");
let secondaryCollection = require("./models/secondaryCollection");
let ternaryCollection = require("./models/ternaryCollection");
let callbackFn = require("./migrations/updateNewFieldsInDB);
// the callbackFn should consists of what logic you want to impliment on per record basis, as this will be called inside a loop.
processMigration( { uri:mongoDB_URI, options: {
// this includes further options that you want to pair up with mongodb
}},
primaryCollection,
[ primaryCollection, secondaryCollection, ternaryCollection ],
callbackFn( data, primaryCollection, secondaryCollection, ternaryCollection, writeLog ) // spread apart your collections here
// you can use writeLog function to write your logs on system which will get saved inside a folder migrationLogs
)
/**
writeLog(action, logContent);
you can directly call this function inside your callback
*/
Coming Soon
Improved overall Performance. Improved logging capabilities. Rollback support.
