connect()
This function is used to connect simply-xp to a database, and configure client options.
Parametersβ
Parameter | Type | Required | Description |
---|---|---|---|
uri | string | β | The URI to connect to the database. |
options | ConnectionOptions | β | The options to configure the client. |
Returnsβ
- Promise<
boolean
> - If the connection was successful.
Throwsβ
XpFatal
- If the connection was unsuccessful, or if the URI is invalid.
[JS] Exampleβ
const {connect} = require('simply-xp');
connect('path/to/file.sqlite') // Returns Promise<boolean>
.then(console.log) // Returns true if connection was successful
.catch((err) => console.log(err)); // Returns the error