Todo example
This commit is contained in:
parent
bd44dc5824
commit
fc8afa066e
|
@ -1,12 +1,7 @@
|
||||||
{
|
{
|
||||||
"production": {
|
"production": {
|
||||||
"module": "mongo",
|
"dependencies": {
|
||||||
"options": {
|
"connection": "oracle"
|
||||||
"database": "todos",
|
|
||||||
"port": 5555,
|
|
||||||
"host": "remote.db.com",
|
|
||||||
"username": "foo",
|
|
||||||
"password": "bar"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue