refactor: delete destroyAll
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-10-26 09:30:17 +02:00
parent 07a18dc736
commit 21e2945d4f
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
module.exports = Self => {
Self.remoteMethod('deleteItemShelvings', {
description: 'Deletes the selected orders',
description: 'Deletes the selected item shelvings',
accessType: 'WRITE',
accepts: [{
arg: 'itemShelvingIds',
@ -32,9 +32,13 @@ module.exports = Self => {
}
try {
const deletedItemShelvings = await models.ItemShelving.destroyAll({
id: {inq: itemShelvingIds}
}, myOptions);
const promises = [];
for (let itemShelvingId of itemShelvingIds) {
const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions);
promises.push(itemShelvingToDelete);
}
const deletedItemShelvings = await Promise.all(promises);
if (tx) await tx.commit();

View File

@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => {
const itemShelvingIds = [1, 2];
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
expect(result.count).toEqual(2);
expect(result.length).toEqual(2);
await tx.rollback();
} catch (e) {