import type { Db } from 'mongodb'; import type { IContainer } from 'node-cqrs'; /** * Abstract base class for accessing a MongoDB database. * * Manages the database connection lifecycle, ensuring initialization via `assertConnection`. * Supports providing a Db instance directly or a factory function for lazy initialization. * * Subclasses must implement the `initialize` method for specific setup tasks * (e.g. creating collections or indexes). */ export declare abstract class AbstractMongoAccessor { #private; protected db: Db | undefined; constructor(c: Partial>); protected abstract initialize(db: Db): Promise | void; /** * Ensures that the MongoDB connection is initialized. * Uses a lock to prevent race conditions during concurrent initialization attempts. * If the database is not already set, it creates one using the provided factory * and then calls the `initialize` method. * * This method is idempotent and safe to call multiple times. */ assertConnection(): Promise; }