I want to run mongod command in node.js using Promises, so that database operations can run only after mongodb process is started. I tried my hands with following, but failed:
var Promise = require("bluebird");
var execAsync = Promise.promisify(require('child_process').exec);
execAsync("~/mongodb/bin/mongod").then(function(result){
console.log("started mongodb...");
}).catch(function(error){
console.log("error in starting mongodb..."+JSON.stringify(error));
});
Any suggestions?