node-db is a set of Node.js bindings for popular relational databases. Its purpose is to provide a common framework from which other database engines can be supported.

How does it look?

node-db is built with ease of use in mind. You can build manual SQL queries, or use the wrapper methods that include auto-escaping. Here is a small example showing how to connect to a MySQL database (using the db-mysql driver), and perform a selection of records based on a set of conditions:

var mysql = require("db-mysql");
new mysql.Database({
    "hostname": "localhost",
    "user": "user",
    "password": "password",
    "database": "test"
}).connect(function(error) {
    if (error) {
        return console.log("CONNECTION error: " + error);
    }
    this.query()
        .select(["id", "user", "email"])
        .from("users")
        .where("role IN ?", [ ["administrator", "user"] ])
        .and("created > ?", [ new Date(2011, 1, 1) ])
        .execute(function(error, rows, columns){
            if (error) {
                console.log('ERROR: ' + error);
                return;
            }
            // Do something with rows & columns
        });
});

Supported databases

These are the currently supported database engines and their correspondent node-db driver:

Performance

node-db is developed with C++, and it is as fast as any other binary binding currently available for node.js. When performance is a major factor, disabling the automatic SQL to JS native type conversion allows node-db to outperform all other bindings by a factor of at least 200%.