- Mongoose - object data modeling (ODM) library to access a mongoDB data store
- Express web app framework
- Jade template engine
- Connect middleware (cookies, favicon, static files, session management, etc) Note: This is installed by NPM as a dependency for Express.
- twitter bootstrap front end framework
- tbd - login using Google, Facebook, etc (passport?)
- best practices for packages.json (support dev & prod, proper dependency version wild-carding etc.)
Steps:
$ cd ~/dev (assumes ~/dev exists)
$ express appName (pick any valid app name)
$ cd appName
edit package.json to include following dependency line
"mongoose": "*"
$ npm install (install all dependencies)
$ npm start (just test the server starts and works the ^c out of it)
$ mkdir model (create a dir to hold model related files)
$ cd model
edit db.js to contain:
var mongoose = require( 'mongoose' );
var todoSchema = new mongoose.Schema({
item: String,
complete: Boolean,
date: { type: Date, default: Date.now }
});
mongoose.model( 'Todo', todoSchema );
mongoose.connect( 'mongodb://localhost/todoDB' );
add to app.js:
, db = require(
'./model/db'
)
No comments:
Post a Comment