From dd3473b93de05e702c5e604dd903b11692605871 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 12 Jul 2021 12:50:15 +0200 Subject: [PATCH] small refactors correcting constants and adding transactions --- back/methods/user-config/getUserConfig.js | 14 +++++--- .../user-config/specs/getUserConfig.spec.js | 19 ++++++++--- .../claim/back/methods/claim/getSummary.js | 2 +- .../client/back/methods/client/uploadFile.js | 2 +- .../back/methods/entry/editLatestBuys.js | 4 +-- .../methods/invoice-in/specs/filter.spec.js | 34 +++++++++---------- .../methods/invoice-in/specs/summary.spec.js | 6 ++-- .../back/methods/invoiceOut/delete.js | 4 +-- .../methods/invoiceOut/specs/book.spec.js | 10 +++--- .../invoiceOut/specs/createPdf.spec.js | 4 +-- .../methods/invoiceOut/specs/delete.spec.js | 16 ++++----- .../methods/invoiceOut/specs/download.spec.js | 4 +-- .../methods/invoiceOut/specs/filter.spec.js | 22 ++++++------ .../invoiceOut/specs/getTickets.spec.js | 6 ++-- .../methods/invoiceOut/specs/summary.spec.js | 14 ++++---- modules/zone/back/methods/zone/deleteZone.js | 4 +-- 16 files changed, 90 insertions(+), 75 deletions(-) diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js index 663ef71b4..4de8049e7 100644 --- a/back/methods/user-config/getUserConfig.js +++ b/back/methods/user-config/getUserConfig.js @@ -12,18 +12,22 @@ module.exports = function(Self) { } }); - Self.getUserConfig = async ctx => { + Self.getUserConfig = async(ctx, options) => { const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); let userConfig = await models.UserConfig.findOne({ where: {userFk: ctx.req.accessToken.userId} - }); + }, myOptions); const companyFilter = {where: {code: 'VNL'}}; - const company = await models.Company.findOne(companyFilter); + const company = await models.Company.findOne(companyFilter, myOptions); const warehouseFilter = {where: {code: 'ALG'}}; - const warehouse = await models.Warehouse.findOne(warehouseFilter); + const warehouse = await models.Warehouse.findOne(warehouseFilter, myOptions); if (!userConfig) { let newConfig = { @@ -32,7 +36,7 @@ module.exports = function(Self) { userFk: ctx.req.accessToken.userId }; - userConfig = await models.UserConfig.create(newConfig); + userConfig = await models.UserConfig.create(newConfig, myOptions); } return userConfig; }; diff --git a/back/methods/user-config/specs/getUserConfig.spec.js b/back/methods/user-config/specs/getUserConfig.spec.js index c86f3e0f2..8b510a706 100644 --- a/back/methods/user-config/specs/getUserConfig.spec.js +++ b/back/methods/user-config/specs/getUserConfig.spec.js @@ -1,10 +1,21 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('userConfig getUserConfig()', () => { it(`should return the configuration data of a given user`, async() => { - const result = await app.models.UserConfig.getUserConfig({req: {accessToken: {userId: 9}}}); + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; - expect(result.warehouseFk).toEqual(1); - expect(result.companyFk).toEqual(442); + try { + const ctx = {req: {accessToken: {userId: 9}}}; + const result = await models.UserConfig.getUserConfig(ctx, options); + + expect(result.warehouseFk).toEqual(1); + expect(result.companyFk).toEqual(442); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); diff --git a/modules/claim/back/methods/claim/getSummary.js b/modules/claim/back/methods/claim/getSummary.js index d6722d11f..512e4a77f 100644 --- a/modules/claim/back/methods/claim/getSummary.js +++ b/modules/claim/back/methods/claim/getSummary.js @@ -133,7 +133,7 @@ module.exports = Self => { }; promises.push(Self.app.models.ClaimEnd.find(filter, myOptions)); - const res = await Promise.all(promises, myOptions); + const res = await Promise.all(promises); [summary.claim] = res[0]; summary.salesClaimed = res[1]; diff --git a/modules/client/back/methods/client/uploadFile.js b/modules/client/back/methods/client/uploadFile.js index 121c1a567..99ede27c6 100644 --- a/modules/client/back/methods/client/uploadFile.js +++ b/modules/client/back/methods/client/uploadFile.js @@ -79,7 +79,7 @@ module.exports = Self => { promises.push(newClientDms); }); - const resolvedPromises = await Promise.all(promises, myOptions); + const resolvedPromises = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/entry/back/methods/entry/editLatestBuys.js b/modules/entry/back/methods/entry/editLatestBuys.js index 7e6a8a22f..53b92d966 100644 --- a/modules/entry/back/methods/entry/editLatestBuys.js +++ b/modules/entry/back/methods/entry/editLatestBuys.js @@ -66,7 +66,7 @@ module.exports = Self => { const model = models[modelName]; try { - let promises = []; + const promises = []; const targets = lines.map(line => { return line[identifier]; @@ -78,7 +78,7 @@ module.exports = Self => { for (let target of targets) promises.push(model.upsertWithWhere({id: target}, value, myOptions)); - const result = await Promise.all(promises, myOptions); + const result = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 0d7c37461..954a33f98 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -1,8 +1,8 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('InvoiceIn filter()', () => { it('should return the invoice in matching supplier name', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -12,7 +12,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(5); expect(result[0].supplierName).toEqual('Plants SL'); @@ -25,7 +25,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching supplier reference', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -35,7 +35,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].supplierRef).toEqual('1241'); @@ -48,7 +48,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching the serial number', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -58,7 +58,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].serialNumber).toEqual(1002); @@ -71,7 +71,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching the account', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -81,7 +81,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(5); expect(result[0].account).toEqual('4000020002'); @@ -94,7 +94,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching the awb code', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -104,7 +104,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); const firstRow = result[0]; expect(result.length).toEqual(1); @@ -119,7 +119,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching the amount', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -129,7 +129,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].amount).toEqual(64.23); @@ -142,7 +142,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the invoice in matching "from" and "to"', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -155,7 +155,7 @@ describe('InvoiceIn filter()', () => { args: {from, to} }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(6); @@ -167,7 +167,7 @@ describe('InvoiceIn filter()', () => { }); it('should return the booked invoice in', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { @@ -177,7 +177,7 @@ describe('InvoiceIn filter()', () => { } }; - const result = await app.models.InvoiceIn.filter(ctx, {}, options); + const result = await models.InvoiceIn.filter(ctx, {}, options); expect(result.length).toEqual(6); expect(result[0].isBooked).toBeTruthy(); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js index 5fc749548..8ebd68832 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/summary.spec.js @@ -1,12 +1,12 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('invoiceIn summary()', () => { it('should return a summary object containing data from one invoiceIn', async() => { - const tx = await app.models.Entry.beginTransaction({}); + const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; try { - const summary = await app.models.InvoiceIn.summary(1, options); + const summary = await models.InvoiceIn.summary(1, options); expect(summary.supplierRef).toEqual('1234'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/delete.js b/modules/invoiceOut/back/methods/invoiceOut/delete.js index e40fa6e6c..96b5e652e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/delete.js +++ b/modules/invoiceOut/back/methods/invoiceOut/delete.js @@ -22,7 +22,7 @@ module.exports = Self => { Self.delete = async(id, options) => { let tx; - let myOptions = {}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -42,7 +42,7 @@ module.exports = Self => { promises.push(ticket.updateAttribute('refFk', null, myOptions)); }); - await Promise.all(promises, myOptions); + await Promise.all(promises); await invoiceOut.destroy(myOptions); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index 8da5c853d..ee72f2218 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -1,20 +1,20 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('invoiceOut book()', () => { const invoiceOutId = 5; it('should update the booked property', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const originalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId, {}, options); + const originalInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); const bookedDate = originalInvoiceOut.booked; const invoiceOutRef = originalInvoiceOut.ref; - await app.models.InvoiceOut.book(invoiceOutRef, options); + await models.InvoiceOut.book(invoiceOutRef, options); - const updatedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId, {}, options); + const updatedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); expect(updatedInvoiceOut.booked).not.toEqual(bookedDate); expect(updatedInvoiceOut.hasPdf).toBeFalsy(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js index 3372411c1..60dd5576d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/createPdf.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; const got = require('got'); describe('InvoiceOut createPdf()', () => { @@ -19,7 +19,7 @@ describe('InvoiceOut createPdf()', () => { }; spyOn(got, 'stream').and.returnValue(response); - let result = await app.models.InvoiceOut.createPdf(ctx, invoiceId); + const result = await models.InvoiceOut.createPdf(ctx, invoiceId); expect(result.hasPdf).toBe(true); }); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js index 88a69eac5..a662cb318 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/delete.spec.js @@ -1,4 +1,4 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('invoiceOut delete()', () => { @@ -9,12 +9,12 @@ describe('invoiceOut delete()', () => { }; it('should check that there is one ticket in the target invoiceOut', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId, {}, options); - const tickets = await app.models.Ticket.find({where: {refFk: invoiceOut.ref}}, options); + const invoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); + const tickets = await models.Ticket.find({where: {refFk: invoiceOut.ref}}, options); expect(tickets.length).toEqual(1); expect(tickets[0].id).toEqual(3); @@ -27,7 +27,7 @@ describe('invoiceOut delete()', () => { }); it(`should delete the target invoiceOut then check the ticket doesn't have a refFk anymore`, async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -35,11 +35,11 @@ describe('invoiceOut delete()', () => { active: activeCtx }); - await app.models.InvoiceOut.delete(invoiceOutId, options); + await models.InvoiceOut.delete(invoiceOutId, options); - const originalTicket = await app.models.Ticket.findById(3, {}, options); + const originalTicket = await models.Ticket.findById(3, {}, options); - const deletedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId, {}, options); + const deletedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options); expect(deletedInvoiceOut).toBeNull(); expect(originalTicket.refFk).toBeNull(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/download.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/download.spec.js index 09289896f..2d9056708 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/download.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/download.spec.js @@ -1,8 +1,8 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('InvoiceOut download()', () => { it('should return the downloaded fine name', async() => { - let result = await app.models.InvoiceOut.download(1); + const result = await models.InvoiceOut.download(1); expect(result[1]).toEqual('text/plain'); expect(result[2]).toEqual('filename="README.md"'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js index 2762e9bd6..2a530048e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js @@ -1,11 +1,11 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('InvoiceOut filter()', () => { let today = new Date(); today.setHours(2, 0, 0, 0); it('should return the invoice out matching ref', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -15,7 +15,7 @@ describe('InvoiceOut filter()', () => { } }; - const result = await app.models.InvoiceOut.filter(ctx, {}, options); + const result = await models.InvoiceOut.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].ref).toEqual('T4444444'); @@ -28,7 +28,7 @@ describe('InvoiceOut filter()', () => { }); it('should return the invoice out matching clientFk', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -38,7 +38,7 @@ describe('InvoiceOut filter()', () => { } }; - const result = await app.models.InvoiceOut.filter(ctx, {}, options); + const result = await models.InvoiceOut.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].ref).toEqual('T2222222'); @@ -51,7 +51,7 @@ describe('InvoiceOut filter()', () => { }); it('should return the invoice out matching hasPdf', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -61,7 +61,7 @@ describe('InvoiceOut filter()', () => { } }; - const result = await app.models.InvoiceOut.filter(ctx, {}, options); + const result = await models.InvoiceOut.filter(ctx, {}, options); expect(result.length).toEqual(5); @@ -73,7 +73,7 @@ describe('InvoiceOut filter()', () => { }); it('should return the invoice out matching amount', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -83,7 +83,7 @@ describe('InvoiceOut filter()', () => { } }; - const result = await app.models.InvoiceOut.filter(ctx, {}, options); + const result = await models.InvoiceOut.filter(ctx, {}, options); expect(result.length).toEqual(1); expect(result[0].ref).toEqual('T2222222'); @@ -96,7 +96,7 @@ describe('InvoiceOut filter()', () => { }); it('should return the invoice out matching min and max', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { @@ -107,7 +107,7 @@ describe('InvoiceOut filter()', () => { } }; - let result = await app.models.InvoiceOut.filter(ctx, {}, options); + let result = await models.InvoiceOut.filter(ctx, {}, options); expect(result.length).toEqual(3); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/getTickets.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/getTickets.spec.js index fffe4b760..67be3dfac 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/getTickets.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/getTickets.spec.js @@ -1,13 +1,13 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('entry getTickets()', () => { const invoiceOutId = 4; it('should get the ticket of an invoiceOut', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const result = await app.models.InvoiceOut.getTickets(invoiceOutId, {}, options); + const result = await models.InvoiceOut.getTickets(invoiceOutId, {}, options); expect(result.length).toEqual(1); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js index 35bccfa1e..2db4077c3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js @@ -1,12 +1,12 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('invoiceOut summary()', () => { it('should return a summary object containing data from one invoiceOut', async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const result = await app.models.InvoiceOut.summary(1, options); + const result = await models.InvoiceOut.summary(1, options); expect(result.invoiceOut.id).toEqual(1); @@ -18,11 +18,11 @@ describe('invoiceOut summary()', () => { }); it(`should return a summary object containing it's supplier country`, async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const summary = await app.models.InvoiceOut.summary(1, options); + const summary = await models.InvoiceOut.summary(1, options); const supplier = summary.invoiceOut.supplier(); expect(summary.invoiceOut.ref).toEqual('T1111111'); @@ -37,11 +37,11 @@ describe('invoiceOut summary()', () => { }); it(`should return a summary object containing idata from it's tax types`, async() => { - const tx = await app.models.InvoiceOut.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; try { - const summary = await app.models.InvoiceOut.summary(1, options); + const summary = await models.InvoiceOut.summary(1, options); expect(summary.invoiceOut.ref).toEqual('T1111111'); expect(summary.invoiceOut.taxesBreakdown.length).toEqual(2); diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 05ffcda54..fb228bcf4 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -26,7 +26,7 @@ module.exports = Self => { today.setHours(0, 0, 0, 0); let tx; - let myOptions = {}; + const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); @@ -68,7 +68,7 @@ module.exports = Self => { }, myOptions)); } } - await Promise.all(promises, myOptions); + await Promise.all(promises); await models.Zone.destroyById(id, myOptions); if (tx) await tx.commit();