Skip to main content

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>

Options​

connectOptions​

ParameterTypeRequiredDefaultDescription
strictboolean❌falseEnables strict mode in connect
notifyboolean❌trueNotifies 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
})