Initialization
Installation
npm install mongodash
mongodash.init(options) => Promise
mongodash.init(options) => Promise
const mongodash = require('mongodash');
const { MongoClient } = require('mongodb');
mongodash.init({
// connection string
uri: 'mongodb://mongodb0.example.com:27017/myDatabase'
// optional MongoClientOptions, see MongoDB Nodejs driver docs for list of options
clientOptions: {},
// optional, true by default
autoConnect: true,
});
// OR
mongodash.init({
// mongodb instance
mongoClient: new MongoClient('mongodb://mongodb0.example.com:27017/myDatabase'),
// optional, true by default
autoConnect: true,
});
import mongodash from 'mongodash';
import { MongoClient } from 'mongodb';
mongodash.init({
// connection string
uri: 'mongodb://mongodb0.example.com:27017/myDatabase'
// optional MongoClientOptions, see MongoDB Nodejs driver docs for list of options
// useUnifiedTopology: true is set to true if not specified
clientOptions: {},
// optional, true by default
autoConnect: true,
});
// OR
mongodash.init({
// mongodb instance
mongoClient: new MongoClient('mongodb://mongodb0.example.com:27017/myDatabase'),
// optional, true by default
autoConnect: true,
});
That's it! Now you can use all utilities described in the following docs. See the left side panel for the utilities.
Updated over 3 years ago