From 383c2a6c0a82a6ffbe2dcc306ed8796fdf202f14 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Feb 2021 13:18:59 +0000 Subject: [PATCH 1/2] Quick fix to make sure all relationships link to a valid, existing doc. --- packages/server/src/db/linkedRows/LinkController.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 061a9ac1a..dd55ed898 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -138,6 +138,13 @@ class LinkController { // 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 { + await this._db.get(linkId) + } catch (err) { + // skip links that don't exist + continue + } operations.push( new LinkDocument( table._id, From a1de336db93c33919172e0a5465375d6e55b6983 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Feb 2021 13:20:53 +0000 Subject: [PATCH 2/2] Make sure both directions exist. --- packages/server/src/db/linkedRows/LinkController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index dd55ed898..5102e50f0 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -140,7 +140,7 @@ class LinkController { if (linkId && linkId !== "" && linkDocIds.indexOf(linkId) === -1) { // first check the doc we're linking to exists try { - await this._db.get(linkId) + await Promise.all([this._db.get(linkId), this._db.get(row._id)]) } catch (err) { // skip links that don't exist continue