2023-11-10 09:58:58 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('executeProc', {
|
|
|
|
description: 'Return result of procedure',
|
2023-11-14 13:02:40 +00:00
|
|
|
accessType: 'EXECUTE',
|
2023-11-10 09:58:58 +00:00
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'routine',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The routine name',
|
|
|
|
required: true,
|
|
|
|
http: {source: 'path'}
|
|
|
|
},
|
2023-11-14 08:17:46 +00:00
|
|
|
{
|
|
|
|
arg: 'schema',
|
|
|
|
type: 'string',
|
|
|
|
description: 'The routine schema',
|
|
|
|
required: true,
|
|
|
|
},
|
2023-11-10 09:58:58 +00:00
|
|
|
{
|
|
|
|
arg: 'params',
|
|
|
|
type: ['any'],
|
|
|
|
description: 'The params array',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
returns: {
|
|
|
|
type: 'any',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:routine/execute-proc`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-11-14 08:17:46 +00:00
|
|
|
Self.executeProc = async(ctx, routine, schema, params, options) => {
|
|
|
|
const query = `CALL ${schema}.${routine}`;
|
|
|
|
return Self.execute(ctx, 'PROCEDURE', query, params, options);
|
2023-11-13 08:36:20 +00:00
|
|
|
};
|
2023-11-10 09:58:58 +00:00
|
|
|
};
|