exframe-seeding
v2.0.3
Published
Seeding micro-services module
Downloads
3
Readme
Exframe Seeding
A module for seeding the master data for the micro services.
Prerequisites
Node
and npm
should be available.
Usage
- Install exframe-seeding module in your micro service.
npm install exframe-seeding --save
Create a folder for your DB scripts and specify it in the environment variable
DB_SCRIPTS_PATH
(relative path from the root folder for your application). The module looks for a folder db_scripts in the root folder of your micro service by default.The module reads the files in the specified folder sequentially and executes the up method in them. The template for a DB script file is:
const model = require('Schema path');
module.exports = {
up: () => {
return new Promise((resolve, reject) => {
// Modifications in your DB with the provided instance of model
});
}
}
The micro service has to be started with npm, as the package gets the fetches the name of the micro service from
db_scripts
folder of the respective service name.In order to downgrade, you just need to run the command
exframe-downgrade
from an npm script in order for the package to fetch the name of the micro service. This command expectsMONGO_URL
andDB_SCRIPTS_PATH
to be present in the environment variables.