refactor: delete destroyAll
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
07a18dc736
commit
21e2945d4f
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue