databaseConnections

 

This option was added in Profound.js 5.0.0.

This option replaces the dbDriver and connectionDetails options, which are now deprecated. Existing configurations using dbDriver and connectionDetails will continue to work in Profound.js 5.0.0 and later, but those options do not allow for multiple database connections. It's not valid to use both databaseConnections and dbDriver/connectionDetails in the same configuration.

Click here for information on how to modify this option in Profound.js. For Profound.js Spaces, click here.

This option specifies a list of database connections for use with Profound.js's database access APIs. This option must be set to an Array. Each element is an Object with the following properties:

  • name: (String/required): A unique name that will be used to refer to the database connection using the pjs.getDB() API, or by using properties in the Designer.

  • default: (Boolean/optional): If set to true, this connection will be the default. Only one connection can be marked as default. If no connections are marked as default, then the first connection in the array will be the default.

  • driver: (String/required): Valid values are "IBMi" (DB2 for IBM i), "mysql" (MySQL/MariaDB), "mssql" (Microsoft SQL Server), "oracledb" (Oracle Database) and "jsonDB" (Profound.js JSON database). The corresponding driver package must be installed separately in order to use "mysql", "mssql", and "oracledb". See the NPM pages for mysql, mssql, and oracledb for installation instructions.

  • driverOptions: (Object/optional): This value is optional for the IBMi driver, invalid for the jsonDB driver, and required for the mysql, mssql, and oracledb drivers. 

  • credentialsFile: (String/optional): Path to a file containing an encrypted user id / password created by the "store_credentials" utility provided with Profound.js. This is an alternative to specifying the user and password in clear text in the driverOptions object.  (This option is only for the mysql, mssql, and oracledb drivers.  For DB2 for IBM i connections using the Profound.js Connector on IBM i use the connectorCredentials or connectorUser/connectorPassword configuration options instead.) 

The credentialsFile option is available in Profound.js versions 5.4.0 and newer.

 

There is no limit on the number or types of database connections, except that there can be only 1 connection set for the IBMi driver.

When this option is not specified, it defaults to:

databaseConnections: [ { name: "default", default: true, driver: "IBMi" } ]

Creating a Credentials File

To create a credentials file, run the following command from your Profound.js installation directory and enter the desired user id and password when prompted:

node store_credentials.js

The credentials file is decrypted when the Profound.js server starts, and the user id and password are added to the "driverOptions" object like this:

user: "decrypted_userid", password: "decrypted_password",

When using this option, it will always override the "user" and "password" items that may already be defined in the "driverOptions" object.

Driver Comparison

Profound.js
Database Driver

dbDriver
Name

Record
Level
Access

SQL

Required
Components

Supported API

Profound.js
Database Driver

dbDriver
Name

Record
Level
Access

SQL

Required
Components

Supported API

IBM i DB2

"IBMi"

Yes

Yes

Profound.js Connector on IBM i

All Record Level Access API,
All SQL API
Data API

Offline JSON Store
(see offline capabilities)

"jsonDB"

Yes

No

No extra components required

Record Level Access API
(No commitment control or record locking)

MySQL / MariaDB / Amazon Aurora

"mysql"

Yes

Yes

Profound.js Connector for MySQL and mysql npm package

All SQL API
Record Level Access API,
(No commitment control, record locking, or access by RRN)
Data API

Microsoft SQL Server

"mssql"

Yes

Yes

Profound.js Connector for MS SQL Server and mssql npm package

All SQL API
Record Level Access API,
(No commitment control, record locking, or access by RRN)
Data API

Oracle

"oracledb"

Yes

Yes

Profound.js Connector for Oracle and oracledb npm package

All SQL API
Record Level Access API
(No commitment control, record locking, or access by RRN)
Data API

For IBM i DB2, if the IBM i system is remote in relation to the Profound.js server and if you're not starting your session from Genie, then you should also set the connectorURL and connectorCredentials configuration settings.

Additional Driver Options for IBM i DB2

Connecting to other databases

Connecting to databases for which a driver does not exist is accomplished through standard NPM packages and Fibers.

For example, a Profound.js module to connect to a MongoDB database and retrieve certain documents from this database might look as follows:

Example

Configuration for Profound.js Spaces

In Profound.js Spaces, this setting can be configured by adding a property called "databaseConnections" to the workspace settings file at Workspace Files/.noderun/settings.json. The following differences apply to Profound.js Spaces:

  • The setting must be specified in JSON format, meaning all property names must be quoted.

  • The IBM i driver does not work in Profound.js Spaces. Applications can only connect to IBM i when called via the NODERUN command or program.

  • The database connection names "workspace" and "workspace_ibmi" are reserved and can't be used.

  • If a default connection is not specified, the built-in workspace database is the default database. If a different default is specified, the built-in workspace database can still be accessed by using name "workspace" with pjs.getDB(). 

The setting is applied when the workspace server is started. After making changes, use the option Server→Restart App Server in the IDE to apply the configuration. The setting is not validated until server startup time, and the server will fail to start if there are any problems. To troubleshoot, check the server logs using the option Server→View Server Logs.

Example for Profound.js Spaces