connectVersion: v1.2
目次
connect()
このコンテンツはまだ日本語訳がありません。
This function is used to connect simply-xp to a database, and configure client options.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| db | string | ✅ | MongoDB Connection String |
| options | ConnectionOptions | ❌ | The options for the user. |
Returns
Section titled “Returns”- Promise<
void>
Throws
Section titled “Throws”new Error()- If the URI was not provided.
[JS] Example
Section titled “[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 errorConnection Options
Section titled “Connection Options”| Parameter | Type | Required | Description |
|---|---|---|---|
| notify | boolean | ❌ | Log { XP } Database Connected. [Default: true] |