Skip to content

Instantly share code, notes, and snippets.

@DamianRivas
Created June 10, 2019 02:49
Show Gist options
  • Save DamianRivas/2c932eb690a73d8ffdd50b6ed8a8e7c8 to your computer and use it in GitHub Desktop.
Save DamianRivas/2c932eb690a73d8ffdd50b6ed8a8e7c8 to your computer and use it in GitHub Desktop.
'use strict';
module.exports = (sequelize, DataTypes) => {
var Banner = sequelize.define('Banner', {
source: DataTypes.STRING,
description: DataTypes.STRING,
topicId: {
type: DataTypes.INTEGER,
onDelete: "CASCADE",
references: {
model: "Topics",
key: "id",
as: "topicId"
}
}
}, {});
Banner.associate = function(models) {
// associations can be defined here
Banner.belongsTo(models.Topic, {
foreignKey: "topicId",
onDelete: "CASCADE"
})
};
return Banner;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment