1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2024-12-01 13:20:54 +00:00

Reflect upsert in update code example

This commit is contained in:
Romein van Buren 2023-01-18 13:40:13 +01:00
parent af72f76350
commit f7c8f9b807
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -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;
}