From 62c506952839dd2ed37e693d606ae2713e833393 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 25 Feb 2021 11:59:31 +0000 Subject: [PATCH] refactor --- packages/server/src/db/linkedRows/LinkController.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 4535cb0274..9230c62e73 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -148,8 +148,9 @@ class LinkController { const linkedTable = await this._db.get(field.tableId) const linkedSchema = linkedTable.schema[field.fieldName] - if (linkedSchema.relationshipType === "one-to-many") { - for (let linkId of rowField) { + // iterate through the link IDs in the row field, see if any don't exist already + for (let linkId of rowField) { + if (linkedSchema.relationshipType === "one-to-many") { const links = await getLinkDocuments({ appId: this._appId, tableId: field.tableId, @@ -164,12 +165,8 @@ class LinkController { `1:N Relationship Error: Record already linked to another.` ) } - console.log("ONE TO MANY") } - } - // iterate through the link IDs in the row field, see if any don't exist already - for (let linkId of rowField) { if (linkId && linkId !== "" && linkDocIds.indexOf(linkId) === -1) { // first check the doc we're linking to exists try {