THT is in early Beta. We welcome contributors & feedback.

Db.use

Db.use(databaseId)

Description

Get the handle for a database other than default (as configured in settings/app.jcon).

Example configuration of a 'sales' database:

{
    app: {
        // ...
    }

    databases: {

        default: {
            file: app.db 
        }

        sales: {
            driver: 'mysql',
            server: 'localhost',
            database: 'sales',
            username: 'dbuser',
            password: 'maknmoney$'
        }
    }
}

All Db functions can be called directly on this handle.

let dbSales = Db.use('sales');

let sql = L'SELECT SUM(price) as total FROM monthlySales';
let totalMonthlySales = dbSales.selectRow(sql);