@warlock.js/cascade
Version:
ORM for managing databases
45 lines • 1.3 kB
TypeScript
import type { MongoClientOptions } from "mongodb";
import { MongoClient } from "mongodb";
import { Database } from "./database";
import type { DatabaseConfigurations } from "./types";
export type ConnectionEvent = "connected" | "error" | "close";
export declare class Connection {
/**
* Mongo Client
*/
client: MongoClient;
/**
* Database instance
*/
database: Database;
/**
* A flag to check if the connection is established
*/
protected isConnectionEstablished: boolean;
/**
* Database configurations
*/
configurations: DatabaseConfigurations;
/**
* Connect to the database
*/
connect(databaseConfigurations?: DatabaseConfigurations & MongoClientOptions): Promise<void>;
/**
* Check if the connection is established
*/
isConnected(): boolean;
/**
* Trigger the given event
*/
protected trigger(eventName: ConnectionEvent, ...args: any[]): any;
/**
* Subscribe to one of connection events
*/
on(eventName: ConnectionEvent, callback: any): import("@mongez/events").EventSubscription;
/**
* Use another database
*/
useDatabase(name: string): Database;
}
export declare const connection: Connection;
//# sourceMappingURL=connection.d.ts.map