API Docs for: 2.6
Show:

dbconn Class

Module: dbconn

Provides the database functionalities.

Methods

config

(
  • path
)

Sets the log level used to debug the sequelize library.

Parameters:

  • path String

    The file path of the static JSON configuration file.

configDbDynamic

(
  • path
)

Sets the dynamic configurations to be use by database connections.

Parameters:

  • path String

    The file path of the dynamic JSON configuration file.

configDbStatic

(
  • path
)

Sets the static configurations to be use by database connections.

Parameters:

  • path String

    The file path of the static JSON configuration file.

emit

(
  • ev
  • data
)

Emit an event. It's the same of nodejs events.EventEmitter.emit method.

Parameters:

  • ev String

    The name of the event

  • data Object

    The object to be emitted

getMssqlTdsVersion

(
  • type
)
String private

Returns the TDS version for MSSQL from the database type configuration. The type has the format "mssql:TDS_VERSION", for example "mssql:7_4".

Parameters:

  • type String

    The database type expressed in the configuration file

Returns:

String:

The TDS version to be used for connection.

getStats

() Object

Returns the statistics.

Returns:

Object:

The statistics.

importModels

() private

Load all sequelize models that are present in the default directory as a file, one for each model. This method must be called after initConnections method.

incNumExecQueries

()

Increment the number of executed queries by one unit.

initConnections

() private

Initialize all database connections.

initMssqlConn

(
  • name
  • tdsVersion
)
private

Initialize an MSSQL connection.

Parameters:

  • name String

    The customer card name

  • tdsVersion String

    The TDS version to be used in connection

isMssqlType

(
  • type
)
Boolean private

Checks if the configuration database type is MSSQL. When it is true, the type has the format "mssql:TDS_VERSION", for example "mssql:7_4".

Parameters:

  • type String

    The database type expressed in the configuration file

Returns:

Boolean:

True if the type is MSSQL.

on

(
  • type
  • cb
)
Object

Subscribe a callback function to a custom event fired by this object. It's the same of nodejs events.EventEmitter.on method.

Parameters:

  • type String

    The name of the event

  • cb Function

    The callback to execute in response to the event

Returns:

Object:

A subscription handle capable of detaching that subscription.

setLogger

(
  • log
)
static

Set the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

Properties

config

Object private

The configurations to be used by database connections.

Default: {}

dbConn

Object private

The database connections.

Default: {}

emitter

Object private

The event emitter.

EVT_READY

String

The name of the ready event.

Default: "ready"

IDLOG

String private final

The module identifier used by the logger.

Default: [dbconn]

JSON_KEYS

Object private

The key names of the JSON files that contains database connection informations.

Default: { CEL: "cel", POSTIT: "postit", VOICEMAIL: "voicemail", PHONEBOOK: "phonebook", QUEUE_LOG: "queue_log", SMS_HISTORY: "sms_history", CALLER_NOTE: "caller_note", QUEUE_RECALL: "queue_recall", HISTORY_CALL: "history_call", CTI_PHONEBOOK: "cti_phonebook", USER_SETTINGS: "user_settings" }

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

logSequelize

Boolean private

True if the sequelize library will be logged. It's customized by the config method.

Default: false

models

Object private

It contains the sequelize models.

Default: {}

numExecQueries

Number private

The number of executed queries.

Default: 0

Events

ready

Fired when the component is ready.