Last active
July 1, 2020 11:14
-
-
Save kianaditya/759511024ffd100c5796d1e7bd367c80 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 db = require('../models') | |
| exports.getAllPosts = async (req, res, next) => { | |
| const allPosts = await db.Post.findAll({ | |
| attributes: ['id', 'title', 'content'], | |
| include: [{ | |
| model: db.User, | |
| as: 'Author', | |
| attributes: ['firstName', 'lastName'], | |
| }] | |
| }) | |
| res.status(200).send(allPosts) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment