-
Notifications
You must be signed in to change notification settings - Fork 2
Home
doix-db is an extension to the doix framework for working with relational databases.
Start a trivial Web service project with doix-http, add a connection to PostgreSQL or to ClickHouse and hack on.
Basically, this is the common database interface for doix, the same as ODBC for Windows, JDBC for Java and so on. Like all those *DBCs, for each individual DBMS, it requires a vendor specific driver.
In application modules, DB connections are available in form of DbClient instances injected as context properties, normally named this.db, this.dbSource, this.dbArchive and so on. Asynchronous methods can be called right away; initialization and cleanup are up to doix internals.
const dt = await this.db.getScalar ('SELECT NOW()')To make injection work, a corresponding DbPool instance must be registered in the hosting Application's pools with the same name:
const {DbPoolPg} = require ('doix-db-postgresql')
// const {DbPoolCh} = require ('doix-db-clickhouse')
///...
pools: {
db : new DbPoolPg (conf.db),
// dbArchive : new DbPoolCh (conf.dbArchive),
},
///...