2023-11-10 09:58:58 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-11-13 08:36:20 +00:00
|
|
|
Self.executeProc = async(ctx, routine, params, schema, options) => {
|
|
|
|
if (schema)
|
|
|
|
routine = schema + '.' + routine;
|
|
|
|
|
|
|
|
const query = `CALL ${routine}`;
|
|
|
|
return Self.execute(ctx, query, params, options);
|
|
|
|
};
|
2023-11-10 09:58:58 +00:00
|
|
|
};
|