I have searched documentation and tried google that, but I did not find a straight answer to the question:
How can I call a stored procedure in Sequelize?
I have searched the documentation of Sequelize but I have even not found a trace of the word "procedure" in that.
The closest I got was this bug-report-turned-feature-request: https://github.com/sequelize/sequelize/issues/959
Quoting from the link:
What I imagine would be awesome:
sequelize.query('CALL calculateFees();').success(
function (settingName1, settingName2, settingName3, users) {
});
They mention that it is possible to call stored procedures, but the syntax is not provided.
Can anyone give me an example with the proper syntax?
Thanks.
sequelize
.query('CALL login (:email, :pwd, :device)',
{replacements: { email: "[email protected]", pwd: 'pwd', device: 'android', }})
.then(v=>console.log(v));
Change success
to spread
and you're good to go. Note that this will only work on sequlize 2.0
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