Browse files

Included sample code on how to link the boilerplate with mongoose.

Also included a simple Post and Comment schema for demonstration.
  • Loading branch information...
1 parent 4d60e45 commit 0af374ab30ed364f983c69e8507b08722020cedb Ed Lau committed Mar 20, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −0 initproject.sh
  2. +2 −1 templates/app/package.json
  3. +6 −0 templates/app/server.js
View
1 initproject.sh
@@ -22,6 +22,7 @@ cp ./templates/views/index.jade ./views/index.jade
cp ./templates/views/layout.jade ./views/layout.jade
cp ./templates/js/script.js ./static/js/script.js
# TODO copy over the models
+cp ./templates/models/post.js ./models/post.js
echo "Setting up the dependancies from NPM..."
npm install
View
3 templates/app/package.json
@@ -8,7 +8,8 @@
"express": "2.5.2",
"jade": "0.20.0",
"mongoose": "2.4.8",
- "socket.io": "0.8.7"
+ "socket.io": "0.8.7",
+ "walk" : "2.0.2"
},
"devDependencies": {
"vows": "0.5.x",
View
6 templates/app/server.js
@@ -2,6 +2,7 @@
var connect = require('connect')
, express = require('express')
, io = require('socket.io')
+ , mongoose = require('mongoose')
, port = (process.env.PORT || 8081);
//Setup Express
@@ -50,6 +51,11 @@ io.sockets.on('connection', function(socket){
});
});
+//Setup Mongoose
+var Schema = mongoose.Schema;
+var ObjectId = Schema.ObjectId;
+require('./models/post.js').make(Schema, mongoose);
+var db = mongoose.connect('mongodb://localhost/boilerplate');
///////////////////////////////////////////
// Routes //

0 comments on commit 0af374a

Please sign in to comment.