Monk constructor.


  1. uri (string or Array): A mongo connection string URI. Replica sets can be an array or comma separated.

  2. [options] (Object): You may optionally specify options.

  3. [callback] (Function): You may optionally specify a callback which will be called once the connection to the mongo database is opened or throws an error.


A Manager instance with the following methods:


const db = require('monk')('localhost/mydb', options)
const db = require('monk')('localhost/mydb,') // replica set
require('monk')('localhost/mydb,').then((db) => {
  // db is the connected instance of the Manager
}).catch((err) => {
  // error connecting to the database


You can set options to pass to every query. By default, monk doesn't set any options.

Set options like this:

db.options = {
  poolSize: 7

results matching ""

    No results matching ""