sequelize.js - Sequelize, Many-To-Many On Non-ID Properties -
i have 1 model, target
, has property/field called targetname
. have second model, operation
, field verb
. both these models have primarykey
field named id
.
i have third model, policy
, defined association/join additional properties; policy
contains targetname
, verb
fields. how specify in belongstomany()
target
, operation
use fields above, instead of defaulting id field? know of through
option specify actual model. what's in ellipsis section below?
target.belongstomany(operation, {through: policy, ...});
, operation.belongstomany(target, {through: policy, ...});
also, specify 2 belongstomany()
?
there no way foreign keys pointing non-primary keys in sequelize. see https://github.com/sequelize/sequelize/issues/2967
Comments
Post a Comment