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. |