Nano
Nano

Reputation: 847

Node app dont connect to the mongodb database

I'm triying to code an app, and i has been researching about my problem... is simple: the mongodb database is not connecting:

npm start
nodemon server.js
7 Dec 11:00:59 - [nodemon] v1.2.1
7 Dec 11:00:59 - [nodemon] to restart at any time, enter `rs`
7 Dec 11:00:59 - [nodemon] watching: *.*
7 Dec 11:00:59 - [nodemon] starting `node server.js`
js-bson: Failed to load c++ bson extension, using pure JS version
running on 8080:

But my mongoose connection logs are not displayed.

var dataBase = {
  dbUri: "mongodb://localhost:27017/omi"
};

var db = mongoose.connection;

db.once('open', function() {
  console.log('base de datos conectada en %s', dataBase.dbUri);
});

db.on('error', function(err) {
  console.log("error: %s", err);
});

Is not complicated and i dont think that is a code problem, i think that is a mongodb problem.

Now, mongd are searching for /data/db but it don't exist, so i changed the confing in /etc/mongodb.conf to /var/lib/mongodb and restarted the process with sudo service mongod restart ... nothing changes.

Any idea? I know that my english is not the best, but for some extra information just ask!

Thanks!

Upvotes: 1

Views: 414

Answers (1)

Nano
Nano

Reputation: 847

My error was simple, i'm working by intertia and, well, i forget to connect to the database...

Yes, i'm a jerk.

mongoose.connect(dataBase.dbUri);

Upvotes: 1

Related Questions