I am looking for a mySQL driver for nodejs that supports stored procedures. http://nodejsdb.org/db-mysql/ that I have been using gives the error
PROCEDURE can\'t r
node-mysql driver work with stored procedure and its very simple just call your stored procedure with parameter.
CREATE PROCEDURE GetAllStudent(id int)
BEGIN
SELECT * FROM student where userid = id ;
END;
and in node just call
app.get('/sp', function (req, res, next) {
connection.connect();
connection.query('CALL GetAllStudent(?)',[req.body.id],function (err, rows, fields) {
if (err) {
res.status(400).send(err);
}
res.status(200).send(rows);
});
connection.end();
});
this way no need to worry of sql injection.
here is good tutorial on nodejs and mysql