connect
Connect to a mongo database to access some of the simply-djs functions ! Requires MongoDB
Implementation
simplydjs.connect('mongodb uri')
INFO
This should be implemented in the main/index file and next to the declaration of the package !
index.js
const simplydjs = require("simply-djs");
simplydjs.connect() // connect function at the next line
Types
simplydjs.connect(
db: string,
options: connectOptions
): Promise<boolean>
db:
string
options:
connectOptions
Resolves:
boolean
(whether connected or not)
Options
connectOptions
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
strict | boolean | ❌ | false | Enables strict mode in connect |
notify | boolean | ❌ | true | Notifies when the mongodb is connected |
export type connectOptions = {
strict?: boolean;
notify?: boolean;
};
Example
Default settings
connect.js
const simplydjs = require('simply-djs')
simplydjs.connect("mongo uri")
Customized with options
connect.js
const simplydjs = require('simply-djs')
simplydjs.connect("mongo uri", {
strict: true,
notify: true
})