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": {
"module": "mongo",
"options": {
"database": "todos",
"port": 5555,
"host": "remote.db.com",
"username": "foo",
"password": "bar"
"dependencies": {
"connection": "oracle"
}
}
}

View File

@ -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');
}
});

View File

@ -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);
});