0

I am trying to build an installation script for an app which made on node.js. As of now, I have to manually install the database dump, run Mongo server, npm packages and run Camunda server. So, is there any way I can do all those things by running a single script.

Please bear with my silly question.

Thanks in advance

nmn_dev
  • 1
  • 3

1 Answers1

0

you can call mongodump command from nodejs as discussed here

about mongo server, you can start it in your app:

import { connect } from 'mongoose'; // MongoDB ORM
connect(conf.db[conf.env], {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false,
  useCreateIndex: true,
})
  .then(() => console.log(`connected to ${conf.db[conf.env]}`))

I need to say above code is written in ES6, if you don't use it you need to set Babel or use older code style:

const mongoose = require('mongoose');
mongoose.connect('url/of/your/db', {
{
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false,
  useCreateIndex: true,
}, function (error) {
  if (error) { // do sth with error 
  }
  console.log('connected successfully');
}

I hope it helps you with your problem

arianpress
  • 456
  • 1
  • 6
  • 16