Created
January 20, 2019 19:17
-
-
Save funador/301290299530e552b43b34a2d09b669a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Todo = require('./model') | |
| exports.addTodo = (req, res) => { | |
| Todo | |
| .create(req.body) | |
| .then(todo => { | |
| res.json(todo) | |
| }) | |
| } | |
| exports.getTodos = (req, res) => { | |
| Todo | |
| .find() | |
| .then(todos => { | |
| res.json(todos) | |
| }) | |
| } | |
| exports.deleteTodo = (req, res) => { | |
| Todo | |
| .findByIdAndRemove(req.params.id) | |
| .then(todo => { | |
| res.json({id: todo._id}) | |
| }) | |
| } | |
| exports.updateTodo = (req, res) => { | |
| Todo. | |
| findByIdAndUpdate(req.params.id, req.body, {new: true}) | |
| .then(todo => { | |
| res.json(todo) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment