mongo-pg-cli
A workspace to work with mongo and postgres client
Installation
npm install -g mongo-pg-cli
How to use :
- Go to workspace parent directory and create config.js
module.exports = {
mongodb: {
uri: process.env.MONGO_URL || 'mongodb://localhost:27017',
options: {
useUnifiedTopology: true
}
},
pg: {
user: 'postgres',
host: '127.0.0.1',
database: 'mydb',
password: 'password',
port: 5432
},
workdir: 'scripts'
};
- Create directory with name according to the config and add file js
{workdir}/filename.js :
module.exports = async (mongoClient, pgClient) => {
console.log('running scripts');
};
- Run script with command below on the same directory with config.js
mongo-pg-cli run <filename>
References
Mongo client and pg client using below references