From 5c46ef2ff496619a8995b1eba6b725a225098c93 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 18 Jan 2022 10:43:21 +0000 Subject: [PATCH] Updating variable naming in table fetch function to match more with what is actually being retrieved. --- .../server/src/api/controllers/table/index.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/server/src/api/controllers/table/index.js b/packages/server/src/api/controllers/table/index.js index 15e869fc75..20dc10017d 100644 --- a/packages/server/src/api/controllers/table/index.js +++ b/packages/server/src/api/controllers/table/index.js @@ -32,8 +32,8 @@ exports.fetch = async function (ctx) { }) ) - const internal = internalTables.rows.map(row => ({ - ...row.doc, + const internal = internalTables.rows.map(tableDoc => ({ + ...tableDoc.doc, type: "internal", sourceId: BudibaseInternalDB._id, })) @@ -44,13 +44,18 @@ exports.fetch = async function (ctx) { }) ) - const external = externalTables.rows.flatMap(row => { - return Object.values(row.doc.entities || {}).map(entity => ({ - ...entity, - type: "external", - sourceId: row.doc._id, - sql: isSQL(row.doc), - })) + const external = externalTables.rows.flatMap(tableDoc => { + let entities = tableDoc.doc.entities + if (entities) { + return Object.values(entities).map(entity => ({ + ...entity, + type: "external", + sourceId: tableDoc.doc._id, + sql: isSQL(tableDoc.doc), + })) + } else { + return [] + } }) ctx.body = [...internal, ...external]