v0.0.4 Add MongoDB - zhentian-wan/MEANAppsFiles GitHub Wiki
Server
First we need to install MongoDB on our computer.
After installation do the following things:
-
We use 'Mongoose' lib:
var mongoose = require('mongoose');
-
Use Mongoose:
//Use Mongoose mongoose.connect('mongodb://localhost/multivision'); // will create multivison databse automatically var db = mongoose.connection;
-
Listen for some events:
db.on('error', console.error.bind(console, 'connection error')); db.once('open', function callback(){ console.log('db opened'); });
RUN MongoDB
In the command line:
mongod // start the mongoDB