From f7c8f9b80710c07036aa8fbba58c910023c04f1b Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Wed, 18 Jan 2023 13:40:13 +0100 Subject: [PATCH] Reflect upsert in update code example --- frontend/src/organisms/connection/collection/update.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/organisms/connection/collection/update.svelte b/frontend/src/organisms/connection/collection/update.svelte index 85afc5d..cbffeda 100644 --- a/frontend/src/organisms/connection/collection/update.svelte +++ b/frontend/src/organisms/connection/collection/update.svelte @@ -46,10 +46,11 @@ let operation = '{ ' + form.parameters.filter(p => p.type).map(p => `${p.type}: ${p.value || '{}'}`).join(', ') + ' }'; if (operation === '{ }') { - operation = ''; + operation = '{}'; } - const code = `db.${collection.key}.${method}(${form.query || '{}'}${operation ? ', ' + operation : ''});`; + const options = form.upsert ? ', { upsert: true }' : ''; + const code = `db.${collection.key}.${method}(${form.query || '{}'}, ${operation}${options});`; return code; }