export interface Entity { _id: TId; } export interface IRepository, TId = string> { findById(id: TId): Promise; save(aggregate: T): Promise; delete(id: TId): Promise; exists(id: TId): Promise; } export interface IQueryableRepository, TId = string, TQuery = Partial> extends IRepository { findAll(query?: TQuery): Promise; findOne(query: TQuery): Promise; count(query?: TQuery): Promise; } export interface IPaginatedRepository, TId = string, TQuery = Partial> extends IQueryableRepository { findPaginated(query: TQuery, options: PaginationOptions): Promise>; } export interface PaginationOptions { offset?: number; limit?: number; sortBy?: string; sortDirection?: 'asc' | 'desc'; } export interface PaginatedResult { items: T[]; totalCount: number; hasMore: boolean; offset: number; limit: number; } export interface IReadOnlyRepository, TId = string, TQuery = Partial> { findById(id: TId): Promise; findAll(query?: TQuery): Promise; findOne(query: TQuery): Promise; count(query?: TQuery): Promise; exists(id: TId): Promise; } export interface IUnitOfWork { begin(): Promise; commit(): Promise; rollback(): Promise; executeInTransaction(fn: () => Promise): Promise; }