Skip to content

Instantly share code, notes, and snippets.

@kianaditya
Last active July 1, 2020 11:14
Show Gist options
  • Save kianaditya/1658a1a9824f2da1d2165794edf1672a to your computer and use it in GitHub Desktop.
Save kianaditya/1658a1a9824f2da1d2165794edf1672a to your computer and use it in GitHub Desktop.
'use strict'
module.exports = (sequelize, DataTypes) => {
const Post = sequelize.define(
'Post',
{
title: DataTypes.STRING,
content: DataTypes.TEXT,
},
{}
)
Post.associate = function (models) {
Post.belongsTo(models.User, { as: 'Author', foreignKey: 'AuthorId' })
}
return Post
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment