dresende/node-orm2

Stored procedure and custom sql statement support for MySql

maneysdev opened this issue · 1 comments

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.

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) { ... }
)