salix/modules/item/back/methods/item-shelving/deleteItemShelvings.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-10-11 06:40:22 +00:00
module.exports = Self => {
Self.remoteMethod('deleteItemShelvings', {
description: 'Deletes the selected orders',
accessType: 'WRITE',
accepts: [{
arg: 'itemShelvingIds',
type: ['number'],
required: true,
description: 'The itemShelving ids to delete'
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/deleteItemShelvings`,
verb: 'POST'
}
});
Self.deleteItemShelvings = async(itemShelvingIds, options) => {
const models = Self.app.models;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try {
const deletedItemShelvings = await models.ItemShelving.destroyAll({
id: {inq: itemShelvingIds}
}, myOptions);
if (tx) await tx.commit();
return deletedItemShelvings;
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
};
};