connect()
This function is used to connect simply-xp to a database, and configure client options.
Parametersβ
Parameter | Type | Required | Description |
---|---|---|---|
db | string | β | MongoDB Connection String |
options | ConnectionOptions | β | The options for the user. |
Returnsβ
- Promise<
void
>
Throwsβ
new Error()
- If the connection was unsuccessful, or if the URI was not provided.
[JS] Exampleβ
const {connect} = require("simply-xp");
const connectionString = "mongodb+srv://myDatabaseUser:D1fficultP%40ssw0rd@cluster0.example.mongodb.net/?retryWrites=true&w=majority";
connect(connectionString) // Returns Promise<void>
.catch((err) => console.log(err)); // Returns the error
Connection Optionsβ
Parameter | Type | Required | Description |
---|---|---|---|
auto_purge | boolean | β | Whether to enable auto purging or not. |
notify | boolean | β | Whether to enable info logging or not. |