From d5e411e9853a4089702120ae93512df3879e474c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 25 Feb 2021 11:05:15 +0000 Subject: [PATCH] 1-n-data-integrity --- packages/server/src/db/linkedRows/LinkController.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index d202c07d63..96074c0ef2 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -132,6 +132,14 @@ class LinkController { const rowField = row[fieldName] const field = table.schema[fieldName] if (field.type === FieldTypes.LINK && rowField != null) { + // if 1:N, ensure that this ID is not already attached to another record + const linkedTable = await this._db.get(field.tableId) + const linkedSchema = linkedTable.schema[field.fieldName] + + if (linkedSchema.relationshipType === "one-to-many") { + + } + // check which links actual pertain to the update in this row const thisFieldLinkDocs = linkDocs.filter( linkDoc =>