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 => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('deleteItemShelvings', {
|
Self.remoteMethod('deleteItemShelvings', {
|
||||||
description: 'Deletes the selected orders',
|
description: 'Deletes the selected item shelvings',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
arg: 'itemShelvingIds',
|
arg: 'itemShelvingIds',
|
||||||
|
@ -32,9 +32,13 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const deletedItemShelvings = await models.ItemShelving.destroyAll({
|
const promises = [];
|
||||||
id: {inq: itemShelvingIds}
|
for (let itemShelvingId of itemShelvingIds) {
|
||||||
}, myOptions);
|
const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions);
|
||||||
|
promises.push(itemShelvingToDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deletedItemShelvings = await Promise.all(promises);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => {
|
||||||
const itemShelvingIds = [1, 2];
|
const itemShelvingIds = [1, 2];
|
||||||
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
|
const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options);
|
||||||
|
|
||||||
expect(result.count).toEqual(2);
|
expect(result.length).toEqual(2);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue