Skip to content

Instantly share code, notes, and snippets.

@kianaditya
Created July 6, 2020 13:12
Show Gist options
  • Save kianaditya/d787e63a25c433410be2f4f87b4f068a to your computer and use it in GitHub Desktop.
Save kianaditya/d787e63a25c433410be2f4f87b4f068a to your computer and use it in GitHub Desktop.
const db = require('../index')
const getUser = async (email) => {
const user = await db.User.findOne({
where: { email: 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: [],
},
},
],
})
return user
}
module.exports = getUser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment