diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index f92e1ea09..22b535f62 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -200,22 +200,20 @@ module.exports = function(Self) { const connector = this.dataSource.connector; let conn; let res; - const opts = Object.assign({}, options); try { if (userId) { - conn = await new Promise((resolve, reject) => { - connector.client.getConnection(function(err, conn) { - if (err) - reject(err); - else - resolve(conn); + if (!options.transaction) { + options = Object.assign({}, options); + conn = await new Promise((resolve, reject) => { + connector.client.getConnection(function(err, conn) { + if (err) + reject(err); + else + resolve(conn); + }); }); - }); - - const opts = Object.assign({}, options); - if (!opts.transaction) { - opts.transaction = { + options.transaction = { connection: conn, connector }; @@ -223,15 +221,14 @@ module.exports = function(Self) { await connector.executeP( 'CALL account.myUser_loginWithName((SELECT name FROM account.user WHERE id = ?))', - [userId], opts + [userId], options ); } - res = await connector.executeP(query, params, opts); + res = await connector.executeP(query, params, options); - if (userId) { - await connector.executeP('CALL account.myUser_logout()', null, opts); - } + if (userId) + await connector.executeP('CALL account.myUser_logout()', null, options); } finally { if (conn) conn.release(); } diff --git a/modules/order/back/methods/order/confirm.js b/modules/order/back/methods/order/confirm.js index 5fdab29b3..1fcb3a760 100644 --- a/modules/order/back/methods/order/confirm.js +++ b/modules/order/back/methods/order/confirm.js @@ -21,7 +21,6 @@ module.exports = Self => { Self.confirm = async(ctx, orderFk) => { const userId = ctx.req.accessToken.userId; - const query = `CALL hedera.order_confirmWithUser(?, ?)`; const response = await Self.rawSql(query, [orderFk, userId], {userId}); diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 7cc300547..4d7fe73d4 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -81,17 +81,15 @@ module.exports = Self => { throw new UserError('You must delete all the buy requests first'); // removes item shelvings - if (hasItemShelvingSales && isSalesAssistant) { - const promises = []; - for (let sale of sales) { - if (sale.itemShelvingSale()) { - const itemShelvingSale = sale.itemShelvingSale(); - const destroyedShelving = models.ItemShelvingSale.destroyById(itemShelvingSale.id, myOptions); - promises.push(destroyedShelving); - } + const promises = []; + for (let sale of sales) { + if (sale.itemShelvingSale()) { + const itemShelvingSale = sale.itemShelvingSale(); + const destroyedShelving = models.ItemShelvingSale.destroyById(itemShelvingSale.id, myOptions); + promises.push(destroyedShelving); } - await Promise.all(promises); } + await Promise.all(promises); // Remove ticket greuges const ticketGreuges = await models.Greuge.find({where: {ticketFk: id}}, myOptions); diff --git a/modules/worker/back/methods/department/getLeaves.js b/modules/worker/back/methods/department/getLeaves.js index 48fe78e08..b1ce2fbe8 100644 --- a/modules/worker/back/methods/department/getLeaves.js +++ b/modules/worker/back/methods/department/getLeaves.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx, ('getLeaves', { + Self.remoteMethodCtx('getLeaves', { description: 'Returns the nodes for a department', accepts: [{ arg: 'parentId',