mongodb , node.js, combbo, deploying on heroku, mongod -


i new mongodb , node.js. have simple node.js app in order run have run command

mongod  

to make sure mongodb running. locally works fine.

now moving heroku, createrd procfile declare :

  web: node http.js 

so take care of starting node.js.

now how can call command

   mongod 

on heroku?

update

before heroku requirement how used initialize mongodb :

 var mongo = require('mongodb');  var server = mongo.server,  db = mongo.db,  bson = mongo.bsonpure,  objectid = mongo.objectid;  var server = new server('localhost', 27017, {auto_reconnect: true});  db = new db('sampledb', server);  db.open(function(err, db) {   if(!err) {      console.log("connected 'sampledb' database");      db.collection('sample', {strict:true}, function(err, collection) {          if (err) {             console.log("the 'sample' collection doesn't exist. creating sample data...");             populatedb();         }     });   } }); 

in order accomodate heroku here how initialize mongodb :

 var mongo = require('mongodb');  var server = mongo.server,  db = mongo.db,  bson = mongo.bsonpure,  objectid = mongo.objectid;    var mongouri = process.env.mongolab_uri ||    process.env.mongohq_url ||    'mongodb://localhost/sampledb';    mongo.db.connect(mongouri, function (err, db) {    db.collection('sample', function(er, collection) {      if (err) {                   console.log("the 'sample' collection doesn't exist. creating              sample data...");                   populatedb();                }   });  }); 

now throws error because db not recognized. think missing conceptual issue here, new world together.

any appreciated.

you don't call command mongod on heroku.

you'd add 1 of mongo add-ons addons.heroku.com app, have code connect credentials in config variable exported app add-on provider.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -