Clean
This commit is contained in:
parent
fcaf657e53
commit
8fa71e2e1b
|
@ -614,7 +614,7 @@ export class ExternalRequest<T extends Operation> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const linkPrimaryKey = this.tables[relatedTableName].primary[0]
|
const linkPrimaryKey = this.tables[relatedTableName].primary[0]
|
||||||
|
|
||||||
const lookupField = isMany ? primaryKey : (field as any).foreignKey
|
const lookupField = isMany ? primaryKey : field.foreignKey
|
||||||
const fieldName = isMany ? field.throughTo || primaryKey : field.fieldName
|
const fieldName = isMany ? field.throughTo || primaryKey : field.fieldName
|
||||||
if (!lookupField || !row[lookupField]) {
|
if (!lookupField || !row[lookupField]) {
|
||||||
continue
|
continue
|
||||||
|
@ -629,10 +629,7 @@ export class ExternalRequest<T extends Operation> {
|
||||||
})
|
})
|
||||||
// this is the response from knex if no rows found
|
// this is the response from knex if no rows found
|
||||||
const rows = !response[0].read ? response : []
|
const rows = !response[0].read ? response : []
|
||||||
const storeTo = isMany
|
const storeTo = isMany ? field.throughFrom || linkPrimaryKey : fieldName
|
||||||
? (field as ManyToManyRelationshipFieldMetadata).throughFrom ||
|
|
||||||
linkPrimaryKey
|
|
||||||
: fieldName
|
|
||||||
related[storeTo] = { rows, isMany, tableId }
|
related[storeTo] = { rows, isMany, tableId }
|
||||||
}
|
}
|
||||||
return related
|
return related
|
||||||
|
|
Loading…
Reference in New Issue