DBMS / 02. Usage
Updated: 13. August 2018
Author: Peter Širka

02. Usage

Professional Support Chat with contributors

This module works with existing database NPM modules.

Initialization

  • 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('postgresql://user:pass@localhost:5432/dbname1');
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();

db.find('table_name').take(100).callback(console.log);
db.find('mypg/table_name').take(100).callback(console.log);
db.find('mynosql/users').take(100).callback(console.log);
db.find('mytable/users').take(100).callback(console.log);