Fixing an issue with complex relationships that are heavily intra-related.
This commit is contained in:
parent
811aa5ced3
commit
7b389180c7
|
@ -387,8 +387,13 @@ exports.fetchEnrichedRow = async function(ctx) {
|
||||||
for (let fieldName of Object.keys(table.schema)) {
|
for (let fieldName of Object.keys(table.schema)) {
|
||||||
let field = table.schema[fieldName]
|
let field = table.schema[fieldName]
|
||||||
if (field.type === FieldTypes.LINK) {
|
if (field.type === FieldTypes.LINK) {
|
||||||
row[fieldName] = linkedRows.filter(
|
// find the links that pertain to this field, get their indexes
|
||||||
linkRow => linkRow.tableId === field.tableId
|
const linkIndexes = linkVals
|
||||||
|
.filter(link => link.fieldName === fieldName)
|
||||||
|
.map(link => linkVals.indexOf(link))
|
||||||
|
// find the rows that the links state are linked to this field
|
||||||
|
row[fieldName] = linkedRows.filter((linkRow, index) =>
|
||||||
|
linkIndexes.includes(index)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue