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.
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.
There is no limit on the number or types of database connections, except that there can be only 1 IBMi connection.
When this option is not specified, it defaults to:
|IBM i DB2||"IBMi"||Yes||Yes||Profound.js Connector on IBM i|
Offline JSON Store
|"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|
|Microsoft SQL Server||"mssql"||Yes||Yes||Profound.js Connector for MS SQL Server and mssql npm package|
|Oracle||"oracledb"||Yes||Yes||Profound.js Connector for Oracle and oracledb npm package|
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:
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.