From 19fb11e69d920da4a45207d9e30df8d957424309 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 =>