Skip to main content
Version: v1

connect()

This function is used to connect simply-xp to a database, and configure client options.

Parameters​

ParameterTypeRequiredDescription
dbstringβœ…MongoDB Connection String
optionsConnectionOptions❌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​

ParameterTypeRequiredDescription
auto_purgeboolean❌Whether to enable auto purging or not.
notifyboolean❌Whether to enable info logging or not.