Closed
Description
I'm trying to set some association options. For example, I have a HasMany
where I want to disallow null in the FK and cascade on delete.
In Sequelize, I'd do something like:
childModel.belongsTo(parentModel, {
foreignKey: {
allowNull: false
},
onDelete: 'CASCADE'
});
I don't see any place in the association attributes or ForeignKey
to pass in those options. See foreign keys (Their documentation on this subject is a bit messy).
I'd like to be able to do the following, using BelongsTo as an example:
export class Child extends Model<Child> {
@BelongsTo(() => Parent, { foreignKey: { allowNull: false }, onDelete: 'CASCADE'})
public parent: Parent;
}
I'm using Sequelize 4, but I think the issue is the same for 3.