import { Model, ModelAggregate, PaginationListing } from "@mongez/monpulse"; import { GenericObject } from "@mongez/reinforcements"; import { CacheDriver } from "../cache"; import { BaseRepositoryManager } from "./base-repository-manager"; import { RepositoryListing } from "./repository-listing"; import { RepositoryManager } from "./repository-manager"; import { CachedRepositoryOptions, FilterByOptions, RepositoryOptions } from "./types"; export declare abstract class RepositoryListManager extends BaseRepositoryManager { /** * List default options */ protected defaultOptions: RepositoryOptions; /** * Default filters list */ protected defaultFilters: FilterByOptions; /** * Filter By options */ protected filterBy: FilterByOptions; /** * List of repositories that should clear its cache when this repository is created, updated or deleted */ protected clearCacheOnUpdate: RepositoryManager[]; /** * Whether to enable caching */ isCacheable: boolean; /** * Cache driver */ protected cacheDriver: CacheDriver; /** * Set the cache driver name * If set, then it will be used instead of the default value in this.cacheDriver */ protected cacheDriverName: string; /** * Constructor */ constructor(); /** * Set cache driver */ setCacheDriver(driver: CacheDriver): this; /** * Get cache driver */ getCacheDriver(): CacheDriver; /** * List All records */ all(options?: Omit): Promise; /** * Get all cached data */ allCached(options?: Omit): Promise; /** * List All Active records */ allActive(options?: Omit): Promise; /** * List all active cached records */ allActiveCached(options?: Omit): Promise; /** * Prepare cache */ prepareCache(): Promise; /** * Cache the given model */ cacheModel(model: T): Promise; /** * Clear the entire cache */ clearCache(): Promise; /** * Before listing * Called before listing records */ beforeListing(_query: ModelAggregate, _options: RepositoryOptions): Promise; /** * On list * Called after listing records */ onList(records: T[]): Promise; /** * Merge default options with the given options */ protected withDefaultOptions(options: RepositoryOptions): { [x: string]: any; defaultLimit?: number; paginate?: boolean; limit?: number; page?: number; select?: string[]; deselect?: string[]; purgeCache?: boolean; orderBy?: string | [string, "asc" | "desc"] | { [key: string]: "asc" | "desc"; }; perform?: (query: ModelAggregate, options: RepositoryOptions) => void; }; /** * Add default filters along side with the given filters */ withDefaultFilters(filters?: FilterByOptions): { [x: string]: any; }; /** * Get new query */ newQuery(): ModelAggregate; /** * An alias to newQuery */ get query(): ModelAggregate; /** * Get cached model */ getCachedModel(id: number): Promise; /** * Get cached model by the given column */ getCachedModelBy(column: string, value: any, cacheKeyOptions?: GenericObject): Promise; /** * Get cached model data */ getCached(id: string | number): Promise; /** * Get active cached model */ getActiveCached(id: string | number): Promise; /** * Generate cache key */ cacheKey(key: string, moreOptions?: GenericObject): string; /** * Get cached data by the given column */ getCachedBy(column: string, value: any, cacheKeyOptions?: GenericObject): Promise; /** * Get and cached value by id then purge it from cache */ getCachedPurge(id: number): Promise; /** * Get and cached by the given column then purge it from cache */ getCachedByPurge(column: string, value: any): Promise; /** * List records */ list(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Find latest records */ latest(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Get latest and active records */ latestActive(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Get oldest records */ oldest(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Get oldest and active records */ oldestActive(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * List cached records */ listCached(options?: CachedRepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Fetch cached records or cache new ones */ cacheList({ key, options, purge, expiresAfter, }: { key?: string; purge?: boolean; expiresAfter?: number; options?: CachedRepositoryOptions; }): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Fetch cached records or cache new ones */ cacheAll({ key, options, expiresAfter, purge, }: { key?: string; purge?: boolean; expiresAfter?: number; options?: CachedRepositoryOptions; }): Promise; /** * Get new repository listing instance */ newList(options?: RepositoryOptions): RepositoryListing; /** * Map the given documents into models */ mapModels(documents: any[]): T[]; /** * Count total records based on the given options */ count(options?: RepositoryOptions): Promise; /** * Count total active records */ countActive(options?: RepositoryOptions): Promise; /** * Get total records based on the given options and cache it */ countCached(options?: RepositoryOptions): Promise; /** * Count active records and cache it */ countActiveCached(options?: RepositoryOptions): Promise; /** * Cache the given key and value */ protected cache(key: string, value: any): Promise; /** * List active cached records */ listActiveCached(options?: CachedRepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * List active records */ listActive(options?: RepositoryOptions): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Chunk records */ chunk(options: RepositoryOptions, callback: (documents: T[], paginationInfo: PaginationListing["paginationInfo"]) => Promise): Promise; /** * Chunk active records */ chunkActive(options: RepositoryOptions, callback: (documents: T[], paginationInfo: PaginationListing["paginationInfo"]) => Promise): Promise; /** * Get active record */ getActive(id: number | string, options?: RepositoryOptions): Promise; /** * Get single record by id */ get(id: number, options?: RepositoryOptions): Promise; /** * Get owned record */ getOwned(userId: number, id: number, column?: string): Promise; /** * Get owned records */ listOwned(userId: number, options?: RepositoryOptions, column?: string): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Get owned active records */ listOwnedActive(userId: number, options?: RepositoryOptions, column?: string): Promise<{ documents: T[]; paginationInfo: PaginationListing; }>; /** * Get first record */ first(options?: RepositoryOptions): Promise; /** * Get first cached record */ firstCached(options?: RepositoryOptions): Promise; /** * Get first active record */ firstActive(options?: RepositoryOptions): Promise; /** * Get first active cached record */ firstActiveCached(options?: RepositoryOptions): Promise; /** * Get last record */ last(options?: RepositoryOptions): Promise; /** * Get last cached record */ lastCached(options?: RepositoryOptions): Promise; /** * Get last active record */ lastActive(options?: RepositoryOptions): Promise; /** * Get last active cached record */ lastActiveCached(options?: RepositoryOptions): Promise; /** * Make filter */ filter(_query: ModelAggregate, _options: RepositoryOptions): Promise; /** * {@inheritdoc} */ orderBy(_options: RepositoryOptions): any; /** * Find By id */ find(id: string | number | T): Promise; /** * Find active document */ findActive(id: string | number | T): Promise; /** * Find by the given column */ findBy(column: string, value: any): Promise; /** * Find by the given column and make sure it is active */ findByActive(column: string, value: any): Promise; /** * Find by the given column and cache it * @alias getCached */ findCached(id: number | string | T): Promise; /** * Find by the given column and cache it * @alias getCachedBy */ findByCached(column: string, value: any): Promise; } //# sourceMappingURL=repository-list-manager.d.ts.map