/** * @module common */ /** End Typedoc Module Declaration */ import { identifier, ModelStatic, AbstractModel } from '../models/model'; import { Injector } from '@angular/core'; import { Collection } from '../models/collection'; import { ValidatorOptions, Validator } from '../validation'; export interface Query { } /** * The abstract store should be the root calls for *all* stores, it provides common methods * for entity validation and storage. */ export declare abstract class AbstractStore { protected modelStatic: ModelStatic; protected injector: Injector; /** * class-validator Validator instance * @see https://github.com/pleerock/class-validator */ protected validator: Validator; constructor(modelStatic: ModelStatic, injector: Injector); /** * Promise that store is initialized. * Override this function for stores that have async initialization like Database stores that * require a connection etc. * @returns {Promise} */ initialized(): Promise; /** * Find one instance by id * @param id * @returns {Promise} */ abstract findOne(id: identifier): Promise; /** * Save the model. Depending on the implementation, this may be a partial save when the model * is known to exist in the store destination and only an update is needed * @param model * @returns {Promise} */ abstract saveOne(model: T): Promise; /** * Check if a model exists in the database * @param model */ abstract hasOne(model: T): Promise; /** * Delete the model from the store. * @param model */ abstract deleteOne(model: T): Promise; /** * Find multiple entities using a query for constraints * @param query * @returns {Promise>} */ abstract findMany(query?: Query): Promise>; /** * Check the entity passed is valid, if not throw ValidationException with the errors * @param model * @param validatorOptions * @returns {Promise} */ validate(model: T, validatorOptions?: ValidatorOptions): Promise | never; /** * Build the entity from data * @param modelData * @returns {Promise} */ hydrate(modelData: any): Promise; }