1.1.4 • Published 10 months ago
@reaperx/grator v1.1.4
grator
Install
$ npm install @reaperx/gratorUsage
We will need to set up the environment variables to connect to mongo database
MONGO_DB_USER=
MONGO_DB_PASSWORD=
MONGO_DB_HOST=
MONGO_DB_NAME=create migration
$ npm run grator -c migration_namerun migrations
$ npm run grator -rundo last migration
$ npm run grator -u
Examples
Into migration file we have an instance of the database, this use https://www.npmjs.com/package/mongodb
exports.up = async db => {
   await db.collection('books').update(
    {"reorder": {$exists: true}}, 
    {$rename:{"reorder":"sort"}},
    false,
    true
    );
}
exports.down = async db => {
  
    await db.collection('books').update(
        {"reordenar": {$exists: true}}, 
        {$rename:{"sort":"reorder"}},
        false,
        true
    );
};