UNPKG

arvox-backend

Version:

Un framework backend moderne et modulaire basé sur Hono, TypeScript et l'architecture hexagonale avec authentification Better Auth + Drizzle intégrée

102 lines 3.66 kB
import { IRepository } from '../interfaces/repository.interface'; import { PaginationParams } from '../types/pagination.type'; /** * Base repository class providing common database operations * Uses generic types to ensure type safety across all repositories */ export declare abstract class BaseRepository<TEntity, TId = string> implements IRepository<TEntity, TId> { /** * Find entity by ID * @param id - Entity identifier * @returns Promise with entity or null if not found */ abstract findById(id: TId): Promise<TEntity | null>; /** * Find all entities with optional pagination * @param pagination - Optional pagination parameters * @returns Promise with array of entities */ abstract findAll(pagination?: { skip: number; limit: number; }): Promise<TEntity[]>; /** * Create new entity * @param data - Data for entity creation * @returns Promise with created entity */ abstract create(data: Omit<TEntity, 'id' | 'createdAt' | 'updatedAt'>): Promise<TEntity>; /** * Update existing entity * @param id - Entity identifier * @param data - Partial data for update * @returns Promise with updated entity */ abstract update(id: TId, data: Partial<Omit<TEntity, 'id' | 'createdAt' | 'updatedAt'>>): Promise<TEntity>; /** * Delete entity by ID * @param id - Entity identifier * @returns Promise with boolean indicating success */ abstract delete(id: TId): Promise<boolean>; /** * Count total entities matching optional criteria * @param criteria - Optional search criteria * @returns Promise with total count */ abstract count(criteria?: any): Promise<number>; /** * Check if entity exists by ID * @param id - Entity identifier * @returns Promise with boolean indicating existence */ exists(id: TId): Promise<boolean>; /** * Find entities by IDs * @param ids - Array of entity identifiers * @returns Promise with array of found entities */ findByIds(ids: TId[]): Promise<TEntity[]>; /** * Soft delete entity (if supported by implementation) * @param id - Entity identifier * @returns Promise with boolean indicating success */ softDelete(id: TId): Promise<boolean>; /** * Restore soft deleted entity (if supported by implementation) * @param id - Entity identifier * @returns Promise with restored entity or null */ restore(_id: TId): Promise<TEntity | null>; /** * Find entities with search functionality * @param searchTerm - Search term * @param searchFields - Fields to search in * @param pagination - Optional pagination * @returns Promise with search results */ findWithSearch(_searchTerm: string, _searchFields: string[], _pagination?: PaginationParams): Promise<{ data: TEntity[]; total: number; }>; /** * Create multiple entities in batch * @param dataArray - Array of creation data * @returns Promise with array of created entities */ batchCreate(dataArray: any[]): Promise<TEntity[]>; /** * Update multiple entities in batch * @param updates - Array of update objects with id and data * @returns Promise with array of updated entities */ batchUpdate(updates: any[]): Promise<TEntity[]>; /** * Delete multiple entities in batch * @param ids - Array of entity identifiers * @returns Promise with success status */ batchDelete(ids: TId[]): Promise<boolean>; } //# sourceMappingURL=base-repository.d.ts.map