-
-
Save amandeepmittal/04a8fb075728d9b886dd2ee373c89a29 to your computer and use it in GitHub Desktop.
This file contains 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('../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