import { MongoClientOptions } from 'mongodb'; import { IQuickMongoEvents } from '../types/Database'; import { Emitter } from './utils/Emitter'; import { QuickMongo } from './QuickMongo'; /** * Quick Mongo Client class. * * Type parameters: * * - `TInitialDatabaseData` (`object`) - The type of the object to be set in new empty databases. * * @template TInitialDatabaseData (`object`) - The type of the object to be set in new empty databases. * * @example * const { QuickMongoClient, QuickMongo } = require('quick-mongo-super') * * // Create a normal Quick Mongo client. * const quickMongoClient = new QuickMongoClient(connectionURI) * * // You can also specify the initial data that will be put * // on successful connection in every database if it's empty. * const quickMongoClient = new QuickMongoClient(connectionURI, {}) * * // Initialize the database. * const mongo = new QuickMongo(quickMongoClient, { * name: 'databaseName', * collectionName: 'collectionName' // optional * }) * * @extends {Emitter} */ export declare class QuickMongoClient = any> extends Emitter> { /** * The MongoDB cluster connection URI to connect to. * @type {string} * @private */ private _connectionURI; /** * Determines if the MongoDB cluster connection is established. * @type {boolean} */ connected: boolean; /** * Array of initialized QuickMongo database instances. * @type {QuickMongo[]} */ databases: QuickMongo[]; /** * An object to put in database on successful connection if the database is empty. * @type {TInitialDatabaseData} */ initialDatabaseData: TInitialDatabaseData; /** * MongoDB client connection options. * @type {MongoClientOptions} */ mongoClientOptions?: MongoClientOptions; readonly [Symbol.toStringTag] = "QuickMongoClient"; /** * Creates a new instance of Quick Mongo Client. * * Type parameters: * * - `TInitialDatabaseData` (`object`) - The type of the object to be set in new empty databases. * * @param {string} connectionURI The MongoDB cluster connection URI to connect to. * @param {TInitialDatabaseData} initialDatabaseData * The database object to set in database if the database is empty on initialation. * * @param {MongoClientOptions} mongoClientOptions MongoDB client connection options. * * @template TInitialDatabaseData (object) - The type of the object to be set in new empty databases. * * @example * const { QuickMongoClient, QuickMongo } = require('quick-mongo-super') * * // Create a normal Quick Mongo client. * const quickMongoClient = new QuickMongoClient(connectionURI) * * // You can also specify the initial data that will be put * // on successful connection in every database if it's empty. * const quickMongoClient = new QuickMongoClient(connectionURI, { * somethingToSetInDatabase: 'something' * }) * * // Initialize the database. * const mongo = new QuickMongo(quickMongoClient, { * name: 'databaseName', * collectionName: 'collectionName' // optional * }) */ constructor(connectionURI: string, initialDatabaseData?: TInitialDatabaseData, mongoClientOptions?: MongoClientOptions); /** * Opens a connection to a MongoDB cluster. * @returns {Promise>} Connected QuickMongoClient instance. */ connect(): Promise>; /** * Closes the connection to a MongoDB cluster. * * This will also disconnect all the instances of `QuickMongo` database class from the MongoDB cluster. * @returns {Promise} */ disconnect(): Promise; }