fix: belongsTo's associatedKey is Model.primaryKeyAttribute

This commit is contained in:
chenos 2020-12-22 19:02:05 +08:00
parent 40bcfb7edc
commit a494185dd7

View File

@ -24,7 +24,8 @@ export async function associated(ctx: Context, next: Next) {
switch (true) {
case field instanceof BELONGSTO:
key = field.options.targetKey || Model.primaryKeyAttribute;
// 如fields.collection对应的 API 为 /fields/119/collection此时 key 为 PK
key = Model.primaryKeyAttribute;
break;
case field instanceof HASONE:
case field instanceof HASMANY: