I am using MySQL
and strongloop
, I have a stored procedure to swap data
swap_XYZ('<old_abc>', '<new_new>')
I am not able to find any example in the documentation to call stored procedure. How to call this stored procedure? Thanks in advance.
module.exports = function (ABCModel) {
var ds = app.dataSources.dsMySQL;
ABCModel.swap = function (old_abc, new_abc, cb) {
var sql = "CALL `swap_XYZ`('" + old_abc + "','" + new_abc + "');";
ds.connector.query(sql, function (err, data) {
if (err) {
console.log("Error:", err);
}
cb(null, data);
console.log("data:", data);
});
}
ABCModel.remoteMethod(
'swap',
{
accepts: [
{arg: 'old_abc', type: 'string'},
{arg: 'new_abc', type: 'string'}
],
returns: {arg: 'result', type: 'object'},
http: {path: '/swap', verb: 'post'}
}
);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With