node-mysql-oil

node-mysql-oil is my thin, slick layer on top @felixge’s awesome node-mysql.

It aims to make SQL more JavaScripty by expressing SQL statements as literal data structures instead of dumb strings.

So instead of this:

db.query(
  'insert into t_test '+
  '(c_user, c_pass, c_uid) '+
  'values ("root", "pass", 501)'
);

You can write this:

db({
  insert_into: 't_test',
  values:{
    c_user: 'root',
    c_pass: 'pass',
    c_uid: 501
    }
});

JavaScript Strings, Numbers, Booleans and Dates are automatically marshaled into their SQL form.

See the project’s README for more information on security (pretty good) and installation (npm-one-liner).

node.js Apr 1 2011