Skip to content
do- edited this page Apr 28, 2025 · 161 revisions

doix-db is an extension to the doix framework for working with relational databases.

tl;dr

Start a trivial Web service project with doix-http, add a connection to PostgreSQL or to ClickHouse and hack on.

Description

Basically, this is the common database interface for doix, the same as ODBC for Windows, JDBC for Java and so on.

Connecting & Using

For an Application to operate on a database, the properly configured vendor specific DbPool must be registered there:

const {DbPoolPg} = require ('doix-db-postgresql')
// const {DbPoolCh} = require ('doix-db-clickhouse')

///...
      pools: {
        db        : new DbPoolPg (conf.db),       
//      dbArchive : new DbPoolCh (conf.dbArchive),
      },
///...

Then, corresponding DbClient instances will be automatically injected in execution contexts:

const dt = await this.db.getScalar ('SELECT NOW()')

Asynchronous methods can be called right away; initialization and cleanup are up to doix internals.

Reference

Clone this wiki locally