import type { DataMigrator } from './plugins/migration'; import { DocumentCache } from './doc-cache'; import { QueryCache } from './query-cache'; import { ChangeEventBuffer } from './change-event-buffer'; import { Subscription, Observable } from 'rxjs'; import type { KeyFunctionMap, MigrationState, RxCollection, RxDatabase, RxQuery, RxDocument, RxDumpCollection, RxDumpCollectionAny, MangoQuery, MangoQueryNoLimit, RxCacheReplacementPolicy, RxStorageWriteError, RxChangeEvent, RxChangeEventInsert, RxChangeEventUpdate, RxChangeEventDelete, RxStorageInstance, CollectionsOfDatabase, RxConflictHandler, MaybePromise, CRDTEntry, MangoQuerySelectorAndIndex } from './types'; import { RxSchema } from './rx-schema'; import { WrappedRxStorageInstance } from './rx-storage-helper'; import { IncrementalWriteQueue } from './incremental-write'; declare const HOOKS_WHEN: readonly ["pre", "post"]; type HookWhenType = typeof HOOKS_WHEN[number]; declare const HOOKS_KEYS: readonly ["insert", "save", "remove", "create"]; type HookKeyType = typeof HOOKS_KEYS[number]; export declare class RxCollectionBase { database: RxDatabase; name: string; schema: RxSchema; internalStorageInstance: RxStorageInstance; instanceCreationOptions: InstanceCreationOptions; migrationStrategies: KeyFunctionMap; methods: KeyFunctionMap; attachments: KeyFunctionMap; options: any; cacheReplacementPolicy: RxCacheReplacementPolicy; statics: KeyFunctionMap; conflictHandler: RxConflictHandler; /** * Stores all 'normal' documents */ storageInstance: WrappedRxStorageInstance; readonly timeouts: Set>; incrementalWriteQueue: IncrementalWriteQueue; constructor(database: RxDatabase, name: string, schema: RxSchema, internalStorageInstance: RxStorageInstance, instanceCreationOptions?: InstanceCreationOptions, migrationStrategies?: KeyFunctionMap, methods?: KeyFunctionMap, attachments?: KeyFunctionMap, options?: any, cacheReplacementPolicy?: RxCacheReplacementPolicy, statics?: KeyFunctionMap, conflictHandler?: RxConflictHandler); get insert$(): Observable>; get update$(): Observable>; get remove$(): Observable>; _incrementalUpsertQueues: Map>; synced: boolean; hooks: { [key in HookKeyType]: { [when in HookWhenType]: { series: Function[]; parallel: Function[]; }; }; }; _subs: Subscription[]; _docCache: DocumentCache; _queryCache: QueryCache; $: Observable>; checkpoint$: Observable; _changeEventBuffer: ChangeEventBuffer; /** * When the collection is destroyed, * these functions will be called an awaited. * Used to automatically clean up stuff that * belongs to this collection. */ onDestroy: (() => MaybePromise)[]; destroyed: boolean; prepare(): Promise; migrationNeeded(): Promise; getDataMigrator(): DataMigrator; migrate(batchSize?: number): Observable; migratePromise(batchSize?: number): Promise; insert(json: RxDocumentType | RxDocument): Promise>; bulkInsert(docsData: RxDocumentType[]): Promise<{ success: RxDocument[]; error: RxStorageWriteError[]; }>; bulkRemove(ids: string[]): Promise<{ success: RxDocument[]; error: RxStorageWriteError[]; }>; /** * same as bulkInsert but overwrites existing document with same primary */ bulkUpsert(docsData: Partial[]): Promise[]>; /** * same as insert but overwrites existing document with same primary */ upsert(json: Partial): Promise>; /** * upserts to a RxDocument, uses incrementalModify if document already exists */ incrementalUpsert(json: Partial): Promise>; find(queryObj?: MangoQuery): RxQuery[]>; findOne(queryObj?: MangoQueryNoLimit | string): RxQuery | null>; count(queryObj?: MangoQuerySelectorAndIndex): RxQuery; /** * find a list documents by their primary key * has way better performance then running multiple findOne() or a find() with a complex $or-selected */ findByIds(ids: string[]): RxQuery>>; /** * Export collection to a JSON friendly format. */ exportJSON(): Promise>; exportJSON(): Promise>; /** * Import the parsed JSON export into the collection. * @param _exportedJSON The previously exported data from the `.exportJSON()` method. */ importJSON(_exportedJSON: RxDumpCollectionAny): Promise; insertCRDT(_updateObj: CRDTEntry | CRDTEntry[]): RxDocument; /** * HOOKS */ addHook(when: HookWhenType, key: HookKeyType, fun: any, parallel?: boolean): void; getHooks(when: HookWhenType, key: HookKeyType): { series: Function[]; parallel: Function[]; }; hasHooks(when: HookWhenType, key: HookKeyType): boolean; _runHooks(when: HookWhenType, key: HookKeyType, data: any, instance?: any): Promise; /** * does the same as ._runHooks() but with non-async-functions */ _runHooksSync(when: HookWhenType, key: HookKeyType, data: any, instance: any): void; /** * Returns a promise that resolves after the given time. * Ensures that is properly cleans up when the collection is destroyed * so that no running timeouts prevent the exit of the JavaScript process. */ promiseWait(time: number): Promise; destroy(): Promise; /** * remove all data of the collection */ remove(): Promise; get asRxCollection(): RxCollection; } /** * creates and prepares a new collection */ export declare function createRxCollection({ database, name, schema, instanceCreationOptions, migrationStrategies, autoMigrate, statics, methods, attachments, options, localDocuments, cacheReplacementPolicy, conflictHandler }: any): Promise; export declare function isRxCollection(obj: any): boolean; export {};