1.1.2 • Published 6 years ago

database-js-forward v1.1.2

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

database-js-forward

Build Status

Forwards database-js calls onto a base driver with debug output of SQL commands

About

Database-js-forward takes advantage of the ability to pass a separate driver to the database-js connection. The base driver is chained through database-js-forward, after the SQL is sent to the debug module.

Database-js-forward is compatible with pools from database-js.

Connection Constructor

Use the second parameter of the connection constructor and chain the desired driver.

    const Database = require('database-js2');
    const Forward = require('database-js-forward').Connection;

    var connection = new Database(<URL>, Forward.chain(require(<driver>)));

Enable Debug Output

export DEBUG=database-js-forward

Usage

const Database = require('database-js2').Connection;
const Forward = require('database-js-forward');

(async function() {
    let conn = new Database('database-js-postgres://localhost/tests', Forward.chain(require('database-js-postgres')));
    let stmt = conn.prepareStatement('SELECT * FROM data ORDER BY date DESC LIMIT 1');
    let results;
    try {
        results = await stmt.query();
        console.log(results);
    } catch (err) {
        console.log(err.stack);
    } finally {
        await conn.close();
        process.exit(0);
    }
})();
1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago