Module: utils/databaseUtil

Database Utility for Satoshi Showdown. Provides functionality for connecting to and disconnecting from a MongoDB database using Mongoose. It ensures robust database interactions and handles potential connection and disconnection issues.

Source:

Requires

Methods

(async, inner) connectDatabase() → {Promise.<void>}

Connects to the MongoDB database. This function attempts to establish a connection to MongoDB using Mongoose based on the provided MongoDB URI in environment variables. Logs the connection status and throws an error if connection fails.

Source:
Throws:

Throws an error if the MongoDB URI is not defined or if the connection fails.

Type
Error
Returns:

A promise that resolves when the connection is successful.

Type
Promise.<void>

(async, inner) disconnectDatabase() → {Promise.<void>}

Disconnects from the MongoDB database. This function closes the existing MongoDB connection using Mongoose. Logs the disconnection status and throws an error if disconnection fails.

Source:
Throws:

Throws an error if the disconnection fails.

Type
Error
Returns:

A promise that resolves when the disconnection is successful.

Type
Promise.<void>