DBMS / 02. Usage
Updated: 13. September 2019
Author: Peter Širka

02. Usage

Professional Support Chat with contributors

This module works with existing database NPM modules.


  • this module can work with multiple database engines together

Create a definition file db.js:

const dbms = require('dbms');

// dbms.init([alias], connection_string);
// @alias {String} Optional, alias for connection string (default: 'default')
// @connection_string {String} A connection string to DB

dbms.init('mypg', 'postgresql://user:pass@localhost:5432/dbname2'); // with a name
dbms.init('mynosql', 'nosql'); // It uses Total.js NOSQL
dbms.init('mytable', 'table'); // It uses Total.js TABLE

Simple usage:

// DBMS is a global variable for the entire project
var db = DBMS();


Connection string params

Connection string can contain additional params for some databases.


Param: max

Max pools for pooling. This param supports PostgreSQL only. Default: 4.


Param: min

Min pools for pooling. This param supports PostgreSQL only. Default: 2.


Param: native

Enables a native driver for DB engine. Currently only PostgreSQL supports native driver. Just follow steps on Node PostgreSQL C/C++ Binding. By default is native binding disabled.

Possible values for connection string:


// or


Param: pooling

Enables pooling. This param supports PostgreSQL only. Default: true.

// Disabling via:

// or


Param: ssl

Enables SSL secured connection. By default is ssl disabled.

// or

Param: timeout

Idle timeout in milliseconds. This param supports PostgreSQL only. Default: 1000.