Collection and Client getters
Utility functions for global access to Collections and MongoClient.
getCollection(name [, options]) => Collection
getCollection(name [, options]) => Collection
Get a new instance of a collection. Uses default database determined from the connection string. See official driver documentation for valid options.
const { getCollection } = require('mongodash');
const myCollection = getCollection('myCollectionName');
import { getCollection } from 'mongodash';
const myCollection = getCollection('myCollectionName');
The method just shortens
getMongoClient().db().collection('myCollectionName')
.
getMongoClient() => MongoClient
getMongoClient() => MongoClient
Returns the global instance of MongoClient. See official driver documentation for documentation of MongoClient.
const { getMongoClient } = require('mongodash');
const mongoClient = getMongoClient();
import { getMongoClient } from 'mongodash';
const mongoClient = getMongoClient();
Updated over 3 years ago
Did this page help you?