import { ClassValidate, CollectionState, IModel } from './types'; import CreateIndexResponse = PouchDB.Find.CreateIndexResponse; export declare abstract class PouchCollection, IDType extends string = string> { _state: CollectionState; db: PouchDB.Database; collectionTypeName: string; validate: ClassValidate; _indexes: { fields: (keyof T)[]; name?: string; indexId: string; }[]; idGenerator: (item?: T) => IDType | Promise; constructor(dbname: string, opts?: PouchDB.Configuration.DatabaseConfiguration, validate?: ClassValidate); checkInit(): Promise; /** * Can be overriden by sub classes to do things before collection initialization. * E.g define indexes using this.addIndex etc when initializing the collection */ beforeInit(): Promise; /** * Can be overriden by sub classes to perform actions after initialization. */ afterInit(): Promise; /** * Does the actual work to initialize a collection. */ private runInit; /** * Creates an index. It is highly recommended to Provide a name to reference it later e.g if you ever need to delete it. * @param {(keyof T)[]} fields * @param {string} name * @return {Promise>} */ addIndex(fields: (keyof T)[], name?: string): Promise>; removeIndex(name: string): Promise; find(selector?: Partial | Record, opts?: { sort?: string[]; limit?: number; }): Promise; findOne(selector: Partial | Record): Promise; findOrFail(selector?: Partial | Record, opts?: { sort?: string[]; limit?: number; }): Promise; findOneOrFail(selector: Partial | Record): Promise; findById(_id: IDType): Promise; findByIdOrFail(_id: IDType): Promise; removeById(id: IDType): Promise; remove(item: T): Promise; private setMetaFields; private markDeleted; upsert(item: T, deltaFunc?: (existing: T) => T): Promise; bulkUpsert(items: T[]): Promise>; bulkRemove(items: T[]): Promise>; onChangeUpserted(item: T): Promise; onChangeDeleted(item: T): Promise; onChangeError(error: Error): Promise; }