Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created December 3, 2018 04:35
Show Gist options
  • Save amandeepmittal/04a8fb075728d9b886dd2ee373c89a29 to your computer and use it in GitHub Desktop.
Save amandeepmittal/04a8fb075728d9b886dd2ee373c89a29 to your computer and use it in GitHub Desktop.
const Todo = require('../models').Todo;
const TodoItem = require('../models').TodoItem;
module.exports = {
create(req, res) {
return Todo.create({
title: req.body.title
})
.then(todo => res.status(201).send(todo))
.catch(error => res.status(400).send(error));
},
list(req, res) {
return Todo.findAll({
include: [
{
model: TodoItem,
as: 'todoItems'
}
]
})
.then(todos => res.status(201).send(todos))
.catch(error => res.status(400).send(error));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment