Skip to content

API ConnectionObject

mlaanderson edited this page Dec 12, 2017 · 2 revisions

A ConnectionObject is used to normalize connection parameters for use in a Connection. While a ConnectionObject is not used by users of a Connection, it is used by driver implementers and the structure can be used in place of a URL string.

var connection = new Connection('postgres://user:password@host:5432/database')

Can also be written as

var connection = new Connection({
    DriverName: 'postgres',
    Username: 'user',
    Password: 'password',
    Hostname: 'host',
    Port: 5432,
    Database: 'database'
});

Properties

DriverName

Type: string

The name of the driver module to be loaded. This can be the full module name or path, or it can be a simplified name which will be expanded. If the driver name is simple_name, then the connection will look for database-js-simple_name first, followed by jsdbc-simple_name, and finally simple_name. If all of these fail, then an exception will be thrown.

Username

Type: string

The username for authentication purposes. This can be null or undefined if the database does not require a username.

Password

Type: string

The password for authentication purposes. This can be null or undefined if the database does not require a password.

Hostname

Type: string

The name or IP address of the database host. This can be null or undefined if the database is not IP based. Some drivers will automatically set the driver hostname to localhost if this is omitted.

Port

Type: integer

The IP port number used by the database host. This can be null or undefined if the database is not IP based. Some drivers will automatically set the driver port to the default if this is omitted.

Database

Type: string

The name of the database on a host, or file path to be used by the connection.

Parameters

Type: string

A list of parameters to pass to the driver, separated by &

Clone this wiki locally