salix/loopback/common/methods/application/executeProc.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

module.exports = Self => {
Self.remoteMethodCtx('executeProc', {
description: 'Return result of procedure',
accessType: '*',
accepts: [
{
arg: 'routine',
type: 'string',
description: 'The routine name',
required: true,
http: {source: 'path'}
},
{
arg: 'params',
type: ['any'],
description: 'The params array',
},
{
arg: 'schema',
type: 'string',
description: 'The routine schema',
}
],
returns: {
type: 'any',
root: true
},
http: {
path: `/:routine/execute-proc`,
verb: 'POST'
}
});
Self.executeProc = async(ctx, routine, params, schema, options) => {
if (schema)
routine = schema + '.' + routine;
const query = `CALL ${routine}`;
return Self.execute(ctx, query, params, options);
};
};