June 2014
Intermediate to advanced
696 pages
38h 52m
English
Connecting to a MongoDB database by using Mongoose is very similar to using the connection string method discussed in Chapter 13, “Getting Started with MongoDB and Node.js.” It uses the connection string format and options syntax shown below:
connect(uri, options, [callback])
Note
The Mongoose library must be installed using npm install mongoose to be able to use it in your Node.js applications.
The connect() method is exported at the root level of the mongoose module. For example the following code connects to the words database on the localhost:
var mongoose = require('mongoose');mongoose.connect('mongodb://localhost/words');
Read now
Unlock full access