Skip to content

Instantly share code, notes, and snippets.

@mockra
Created December 27, 2013 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mockra/8142625 to your computer and use it in GitHub Desktop.
Save mockra/8142625 to your computer and use it in GitHub Desktop.
var Todo = require('../models/todo');
exports.index = function(req, res) {
Todo.find(function(err, todos) {
res.send({
todos: todos
});
});
};
exports.create = function(req, res) {
res.send(new Todo(req.body.todo).save());
};
exports.update = function(req, res) {
Todo.findByIdAndUpdate(req.params.id, req.body.todo, function(err, todo) {
res.send(todo);
});
};
exports.destroy = function(req, res) {
Todo.findByIdAndRemove(req.params.id, function(err, todo) {
res.send(todo);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment