1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00
This commit is contained in:
mike12345567 2021-07-01 14:25:23 +01:00
parent bb396ebff0
commit d9aa1360d0
3 changed files with 14 additions and 23 deletions

View file

@ -1,5 +1,9 @@
const { makeExternalQuery } = require("./utils")
const { DataSourceOperation, SortDirection, FieldTypes } = require("../../../constants")
const {
DataSourceOperation,
SortDirection,
FieldTypes,
} = require("../../../constants")
const { getAllExternalTables } = require("../table/utils")
const {
breakExternalTableId,
@ -81,12 +85,7 @@ async function handleRequest(
}
await Promise.all(promises)
}
const output = outputProcessing(
response,
table,
relationships,
tables
)
const output = outputProcessing(response, table, relationships, tables)
// if reading it'll just be an array of rows, return whole thing
return operation === DataSourceOperation.READ && Array.isArray(response)
? output
@ -256,7 +255,11 @@ exports.fetchEnrichedRow = async ctx => {
// this seems like a lot of work, but basically we need to dig deeper for the enrich
// for a single row, there is probably a better way to do this with some smart multi-layer joins
for (let [fieldName, field] of Object.entries(table.schema)) {
if (field.type !== FieldTypes.LINK || !row[fieldName] || row[fieldName].length === 0) {
if (
field.type !== FieldTypes.LINK ||
!row[fieldName] ||
row[fieldName].length === 0
) {
continue
}
const links = row[fieldName]
@ -275,7 +278,7 @@ exports.fetchEnrichedRow = async ctx => {
[linkedTable.primary]: linkedIds,
},
},
},
}
)
}
return row

View file

@ -76,12 +76,7 @@ exports.generateIdForRow = (row, table) => {
return generateRowIdField(idParts)
}
exports.updateRelationshipColumns = (
row,
rows,
relationships,
allTables
) => {
exports.updateRelationshipColumns = (row, rows, relationships, allTables) => {
const columns = {}
for (let relationship of relationships) {
const linkedTable = allTables[relationship.tableName]
@ -109,12 +104,7 @@ exports.updateRelationshipColumns = (
return rows
}
exports.outputProcessing = (
rows,
table,
relationships,
allTables
) => {
exports.outputProcessing = (rows, table, relationships, allTables) => {
// if no rows this is what is returned? Might be PG only
if (rows[0].read === true) {
return []

View file

@ -1,5 +1,3 @@
import {breakExternalTableId} from "../../../integrations/utils"
const CouchDB = require("../../../db")
const csvParser = require("../../../utilities/csvParser")
const {