Aller au contenu principal
Version: v1

connect()

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

Parameters

ParameterTypeRequiredDescription
dbstringMongoDB Connection String
optionsConnectionOptionsThe 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_purgebooleanWhether to enable auto purging or not.
notifybooleanWhether to enable info logging or not.