mongoHandler
function mongoHandler(uri: string, config: Object = {})
async
Connects to a MongoDB database using Mongoose.
Returns: Promise<void>
- Resolves when connected, exits process on failure.
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
uri | string | MongoDB connection URI. | ||
config | Object | ✔️ | Additional Mongoose connection options. See the official mongoose package documentation for more details: |
Throws:
Will log an error and exit the process if the connection fails.
See:
mongoHandler("mongodb://localhost:27017/mydb", { useNewUrlParser: true, useUnifiedTopology: true });