Relation problem (source key and target key)
Issue
Can i define source key and target key manually? i cant use @Primary for parent Model because the parent model have more than 1 key
Versions
^1.1.0
- sequelize: ^5.21.5
- sequelize-typescript: ^1.1.0
- typescript: ^3.8.3
Issue type
- [ ] bug report
- [x ] feature request
YES! I would Like to second this issue!!!! You might change the title:
Allow @ForeignKey annotation to specify any unique column.
@ForeignKey annotation always targets the primary key. Need to be able to specify an alternate.
Constraint will look like:
FOREIGN KEY (changable_localfield_FK) REFERENCES distantTable (FIXED_primaryKey) ON DELETE SET NULL ON UPDATE CASCADE,
While we can change what field is used in the local table to hold the foreign key, we can't seem to specify anything other than the primary key on the "Linked" table.
Quite a few legit scenarios where you may have more than one unique key in the table. e.g. you want to use autoincrement (forces use of Primary key), but you also need to capture a GUID, to ensure unique values across tables.
I also have this need to customize the foreignkey other than using the primary key