From fc8afa066ee6224a682033cb2c523ce09a7a4162 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Mon, 15 Apr 2013 10:14:54 -0700 Subject: [PATCH] Todo example --- example/todos/db/config.env.json | 9 ++------- example/todos/todos/todos.js | 12 ++++++------ node_modules/collection/lib/collection.js | 2 -- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/example/todos/db/config.env.json b/example/todos/db/config.env.json index 402157a4..adced94b 100644 --- a/example/todos/db/config.env.json +++ b/example/todos/db/config.env.json @@ -1,12 +1,7 @@ { "production": { - "module": "mongo", - "options": { - "database": "todos", - "port": 5555, - "host": "remote.db.com", - "username": "foo", - "password": "bar" + "dependencies": { + "connection": "oracle" } } } \ No newline at end of file diff --git a/example/todos/todos/todos.js b/example/todos/todos/todos.js index 0018298e..42b6e55f 100644 --- a/example/todos/todos/todos.js +++ b/example/todos/todos/todos.js @@ -1,16 +1,16 @@ var todos = require('.'); 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) { - if(!todo.name) { - throw new Error('name is required'); +todos.on('validate', function (todo, ctx) { + if(!todo.title) { + throw new Error('title is required'); } - if(todo.name.length > 144) { - ctx.error('name must be shorter than 144 characters'); + if(todo.title.length > 144) { + ctx.error('title must be shorter than 144 characters'); } }); diff --git a/node_modules/collection/lib/collection.js b/node_modules/collection/lib/collection.js index 93ef6466..3c4b1d6b 100644 --- a/node_modules/collection/lib/collection.js +++ b/node_modules/collection/lib/collection.js @@ -69,8 +69,6 @@ Collection.prototype.setupRoutes = function (app) { app.post('/new', create); function create(req, res, next) { - console.log(req.body); - ctx.emit('create', function (done) { Model.create(req.body, done); });