Created
July 1, 2020 12:21
-
-
Save kianaditya/c6d3ebad376d78f7219b76efa8b23bdd 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.getUser = async (req, res, next) => { | |
const user = await db.User.findOne({ | |
where: { email: req.user.email }, | |
attributes: ['firstName', 'lastName'], | |
include: [ | |
{ | |
model: db.Post, | |
as: 'Written', | |
attributes: ['id', 'title', 'content'], | |
}, | |
{ | |
model: db.Post, | |
as: 'Saved', | |
attributes: ['id', 'title', 'content'], | |
through: { | |
attributes: [], | |
}, | |
}, | |
], | |
}) | |
res.status(200).send(user) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment