From d6d314ad3bd6e2ec5182128bd8f7b36e6240ec2b Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 24 Feb 2022 23:06:21 +0000 Subject: [PATCH] Added new lookup capability inside test data object --- utility/db/dbTestData.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utility/db/dbTestData.js b/utility/db/dbTestData.js index 5e907ac..9365785 100644 --- a/utility/db/dbTestData.js +++ b/utility/db/dbTestData.js @@ -356,6 +356,21 @@ async function insertData(dbOptions) { 10); } + + if (record?.lookups) { + delete dataToInsert.lookups; + + for (let [ key, index ] of + Object.entries(record.lookups)) { + + const resolveTable = key.split('Id')[0]; + index--; + + dataToInsert[key] = + data[resolveTable][index][key]; + } + } + data[table][counter] = dataToInsert; const qs = '?, '.repeat(Object.keys(