34 lines
816 B
JavaScript
34 lines
816 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethod('deleteOrders', {
|
|
description: 'Deletes the selected orders',
|
|
accessType: 'WRITE',
|
|
accepts: [{
|
|
arg: 'deletes',
|
|
type: ['number'],
|
|
required: true,
|
|
description: 'The order ids to delete'
|
|
}],
|
|
returns: {
|
|
type: ['object'],
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/deleteOrders`,
|
|
verb: 'POST'
|
|
}
|
|
});
|
|
|
|
Self.deleteOrders = async(deletes = [], options) => {
|
|
const models = Self.app.models;
|
|
|
|
let myOptions = {};
|
|
|
|
if (typeof options == 'object')
|
|
Object.assign(myOptions, options);
|
|
|
|
return models.Order.destroyAll({
|
|
id: {inq: deletes}
|
|
}, myOptions);
|
|
};
|
|
};
|