GoConqr has a new look! Let us know what you think.

Notes

Getting started with Node and Mongo

James Drummond node.js A-Level English 1 page

Content of the notes (1)

Page 1

Great introduction to Express and mongo installation: http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/

You need to 'mongod' from the command line - I think this is the Mongo daemon.

Run 'mongo' from the command line to get a console from which you can run mongo commands.

Connect to the database in app.js:

// Add Mongo connection var mongo = require('mongodb');

var monk = require('monk'); // Allow easy queries on the database

var db = monk('localhost:27017/nodetest1');

// Make our db accessible to our router // THIS CODE MUST BE AHEAD OF THE ROUTES CODE OR THE APP WILL NOT WORK

app.use(function(req,res,next){

req.db = db;

next();

});

app.use('/', routes);

app.use('/users', users);

Information

Description
A-Level node.js Note on Getting started with Node and Mongo, created by James Drummond on 23/02/2015.
Created by
James Drummond
Views
32
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?