salix/services/ticket/common/methods/packaging/listPackaging.js

35 lines
964 B
JavaScript
Raw Normal View History

2018-08-10 09:40:48 +00:00
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('listPackaging', {
description: 'Returns all packages including item',
accessType: 'READ',
accepts: [{
arg: 'filter',
type: 'Object',
required: false,
description: 'Filter defining where and paginated data',
http: {source: 'query'}
}],
returns: {
type: ["Object"],
root: true
},
http: {
path: `/listPackaging`,
verb: 'get'
}
});
Self.listPackaging = async filter => {
2018-08-10 09:40:48 +00:00
let stmt = new ParameterizedSQL(
`SELECT i.name, i.id, p.id packagingFk
FROM item i JOIN packaging p ON i.id = p.itemFk`
);
2018-08-10 09:40:48 +00:00
stmt.merge(Self.buildSuffix(filter, 'i'));
return Self.rawStmt(stmt);
};
};