Skip to content

API ConnectionObject

Michael Anderson edited this page Dec 13, 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

Property Type Description
DriverName 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 string The username for authentication purposes. This can be null or undefined if the database does not require a username.
Password string The password for authentication purposes. This can be null or undefined if the database does not require a password.
Hostname 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 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 string The name of the database on a host, or file path to be used by the connection.
Parameters string A list of additional parameters to pass to the driver, separated by &