@reaperx/grator

1.1.3 • Public • Published

grator

Install


$ npm install @reaperx/grator

Usage


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_name
    
  • run migrations

      $ npm run grator -r
    
  • undo 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
    );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @reaperx/grator

Weekly Downloads

6

Version

1.1.3

License

MIT

Unpacked Size

15.9 kB

Total Files

23

Last publish

Collaborators

  • reaperx