From 8432815cb7d780b51c1bceb823173fcf7fcbc862 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 13 Apr 2022 14:58:46 +0200 Subject: [PATCH] refactor --- modules/entry/back/methods/entry/editLatestBuys.js | 13 ++++--------- .../entry/back/methods/entry/latestBuysFilter.js | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/entry/back/methods/entry/editLatestBuys.js b/modules/entry/back/methods/entry/editLatestBuys.js index 636efb8b4..58d33e183 100644 --- a/modules/entry/back/methods/entry/editLatestBuys.js +++ b/modules/entry/back/methods/entry/editLatestBuys.js @@ -76,19 +76,14 @@ module.exports = Self => { const value = {}; value[field] = newValue; - if (filter) { - const valueData = await model.find(filter, myOptions); - result = await valueData.updateAttribute(field, newValue, myOptions); - - if (tx) await tx.commit(); - - return result; - } + if (filter) + lines = await models.Entry.latestBuysFilter(null, filter, myOptions);// ctx? + // get lines + console.log(lines.length); const targets = lines.map(line => { return line[identifier]; }); - for (let target of targets) promises.push(model.upsertWithWhere({id: target}, value, myOptions)); diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 04570533c..6399faa52 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -86,7 +86,7 @@ module.exports = Self => { } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: {