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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.