Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stored procedure and custom sql statement support for MySql #839

Closed
maneyputha opened this issue Nov 25, 2018 · 1 comment
Closed

Stored procedure and custom sql statement support for MySql #839

maneyputha opened this issue Nov 25, 2018 · 1 comment

Comments

@maneyputha
Copy link

Does this this thing supports stored procedures and custom sql queries ? I have been trying to figure it out for while now. If it does not directly support, at least does this thing has some workaround to make it work ?
Thanks.

@maneyputha
Copy link
Author

Found it !
It's documented under the raw queries section.

db.driver.execQuery("SELECT id, email FROM user", function (err, data) { ... })

// You can escape identifiers and values.
// For identifier substitution use: ??
// For value substitution use: ?
db.driver.execQuery(
  "SELECT user.??, user.?? FROM user WHERE user.?? LIKE ? AND user.?? > ?",
  ['id', 'name', 'name', 'john', 'id', 55],
  function (err, data) { ... }
)

// Identifiers don't need to be scaped most of the time
db.driver.execQuery(
  "SELECT user.id, user.name FROM user WHERE user.name LIKE ? AND user.id > ?",
  ['john', 55],
  function (err, data) { ... }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant