import { JSONObject } from "kuzzle-sdk"; import { cacheDbEnum } from "../cache/cacheDbEnum"; export declare class ObjectRepository { protected ttl: number; protected index: string; protected collection: string; protected ObjectConstructor: any; protected store: any; protected cacheDb: cacheDbEnum; constructor({ cache, store }?: { cache?: cacheDbEnum; store?: any; }); loadOneFromDatabase(id: string): Promise; loadMultiFromDatabase(ids: string[]): Promise; /** * Search in database corresponding repository according to a query * * @param {object} searchBody * @param {object} [options] - optional search arguments (from, size, scroll) * @returns {Promise} */ search(searchBody: any, options?: {}): Promise<{ aggregations: any; hits: any[]; scrollId: any; total: any; }>; /** * Scroll over a paginated search request */ scroll(scrollId: string, ttl?: string | number): Promise<{ aggregations: any; hits: any[]; scrollId: any; total: any; }>; /** * Loads an object from Cache. Returns a promise that resolves either to the * retrieved object of null in case it is not found. * * The opts object currently accepts one optional parameter: key, which forces * the cache key to fetch. * In case the key is not provided, it defaults to repos///, i.e.: repos/%kuzzle/users/12 * * @param id - The id of the object to get * @param options.key - Cache key. */ loadFromCache(id: string, options?: { key?: string; }): Promise; /** * Loads an object from Cache or from the Database if not available in Cache. * Returns a promise that resolves either to the * retrieved object of null in case it is not found. * * If the object is not found in Cache and found in the Database, * it will be written to cache also. * * The opts object currently accepts one optional parameter: key, which forces * the cache key to fetch. * In case the key is not provided, it defaults to /id * (e.g. users/12) * * @param id - The id of the object to get * @param options.key - Optional cache key */ load(id: string, options?: { key?: string; }): Promise; /** * Persists the given object in the collection that is attached to the repository. * * @param object - The object to persist * @param options.method - * @returns {Promise} */ persistToDatabase(object: TObject, options?: any): any; /** * Given an object with an id, delete it from the configured storage engines * * @param object - The object to delete * @param options.key - if provided, removes the given key instead of the default one (/) */ delete(object: TObject, options?: any): Promise; /** * Delete repository from database according to its id */ deleteFromDatabase(id: string, options?: JSONObject): any; /** * Persists the given ObjectConstructor object in cache. * * @param object - The object to persist * @param options.key - if provided, stores the object to the given key instead of the default one (/) * @param options.ttl - if provided, overrides the default ttl set on the repository for the current operation */ persistToCache(object: TObject, options?: { key?: string; ttl?: number; }): Promise; /** * Removes the object from the Cache Engine * * @param id * @param options.key - if provided, stores the object to the given key instead of the default one (/) */ deleteFromCache(id: string, options?: { key?: string; }): Promise; /** * @param object * @param options.key - if provided, stores the object to the given key instead of the default one (/) * @param options.ttl - if provided, overrides the default ttl set on the repository for the current operation */ refreshCacheTTL(object: JSONObject, options?: { key?: string; ttl?: number; }): Promise; /** * @param object * @param options.key - if provided, stores the object to the given key instead of the default one (/) */ expireFromCache(object: TObject, options?: { key?: string; }): Promise; /** * Serializes the object before being persisted to cache. * * @param object - The object to serialize */ serializeToCache(object: TObject): any; /** * Serializes the object before being persisted to the database. * * @param object - The object to serialize */ serializeToDatabase(object: TObject): Omit; /** * @param {string} id */ getCacheKey(id: string): string; /** * @param {object} dto * @returns {Promise} */ fromDTO(dto: JSONObject): Promise; /** * @param {ObjectConstructor} o * @returns {object} */ toDTO(o: TObject): any; /** * Recursively delete all objects in repository with a scroll * * @param {object} options - ES options (refresh) * @param {object} part * @returns {Promise} total deleted objects */ truncate(options: any): Promise; /** * Do not override this: this function calls itself. */ private _truncate; /** * @param {Array} objects * @param {object} options * @returns {Promise} count of deleted objects */ private truncatePart; /** * Given a raw search response from ES, returns a {total: int, hits: []} object * @param {object} raw * @returns {Promise} * @private */ private formatSearchResults; }