Todo example

This commit is contained in:
Ritchie Martori 2013-04-15 10:14:54 -07:00
parent bd44dc5824
commit fc8afa066e
3 changed files with 8 additions and 15 deletions

View File

@ -1,12 +1,7 @@
{ {
"production": { "production": {
"module": "mongo", "dependencies": {
"options": { "connection": "oracle"
"database": "todos",
"port": 5555,
"host": "remote.db.com",
"username": "foo",
"password": "bar"
} }
} }
} }

View File

@ -1,16 +1,16 @@
var todos = require('.'); var todos = require('.');
todos.app.get('/completed', function (req, res) { todos.app.get('/completed', function (req, res) {
todos.store.all({where: {creator: req.me, done: true}}, todos.done); todos.model.all({where: {creator: req.me, done: true}}, todos.done);
}); });
todos.on('before:validate', function (todo, ctx) { todos.on('validate', function (todo, ctx) {
if(!todo.name) { if(!todo.title) {
throw new Error('name is required'); throw new Error('title is required');
} }
if(todo.name.length > 144) { if(todo.title.length > 144) {
ctx.error('name must be shorter than 144 characters'); ctx.error('title must be shorter than 144 characters');
} }
}); });

View File

@ -69,8 +69,6 @@ Collection.prototype.setupRoutes = function (app) {
app.post('/new', create); app.post('/new', create);
function create(req, res, next) { function create(req, res, next) {
console.log(req.body);
ctx.emit('create', function (done) { ctx.emit('create', function (done) {
Model.create(req.body, done); Model.create(req.body, done);
}); });