UNPKG

firewalk

Version:

A collection traversal library for Firestore

33 lines (32 loc) 3.38 kB
import type { firestore } from 'firebase-admin'; import type { BatchCallback, MigrationPredicate, MigrationResult, Migrator, SetDataGetter, SetOptions, SetPartialDataGetter, Traverser, UpdateDataGetter, UpdateFieldValueGetter } from '../../../api'; export type RegisteredCallbacks<AppModelType = firestore.DocumentData, DbModelType extends firestore.DocumentData = firestore.DocumentData> = { onBeforeBatchStart?: BatchCallback<AppModelType, DbModelType>; onAfterBatchComplete?: BatchCallback<AppModelType, DbModelType>; }; export declare abstract class AbstractMigrator<AppModelType = firestore.DocumentData, DbModelType extends firestore.DocumentData = firestore.DocumentData> implements Migrator<AppModelType, DbModelType> { protected readonly registeredCallbacks: RegisteredCallbacks<AppModelType, DbModelType>; protected readonly migrationPredicates: MigrationPredicate<AppModelType, DbModelType>[]; protected constructor(registeredCallbacks?: RegisteredCallbacks<AppModelType, DbModelType>, migrationPredicates?: MigrationPredicate<AppModelType, DbModelType>[]); protected get firestoreInstance(): firestore.Firestore; protected get firestoreConstructor(): typeof firestore; onBeforeBatchStart(callback: BatchCallback<AppModelType, DbModelType>): void; onAfterBatchComplete(callback: BatchCallback<AppModelType, DbModelType>): void; deleteField(field: string | firestore.FieldPath): Promise<MigrationResult>; deleteFields(...fields: (string | firestore.FieldPath)[]): Promise<MigrationResult>; renameField(oldField: string | firestore.FieldPath, newField: string | firestore.FieldPath): Promise<MigrationResult>; renameFields(...changes: [oldField: string | firestore.FieldPath, newField: string | firestore.FieldPath][]): Promise<MigrationResult>; protected migrateWithTraverser(migrateBatch: (batchDocs: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>[]) => Promise<number>): Promise<MigrationResult>; protected shouldMigrateDoc(doc: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>): boolean; abstract readonly traverser: Traverser<AppModelType, DbModelType>; abstract withPredicate(predicate: MigrationPredicate<AppModelType, DbModelType>): Migrator<AppModelType, DbModelType>; abstract withTraverser(traverser: Traverser<AppModelType, DbModelType>): Migrator<AppModelType, DbModelType>; abstract set(data: firestore.PartialWithFieldValue<AppModelType>, options: SetOptions): Promise<MigrationResult>; abstract set(data: firestore.WithFieldValue<AppModelType>): Promise<MigrationResult>; abstract setWithDerivedData(getData: SetPartialDataGetter<AppModelType, DbModelType>, options: SetOptions): Promise<MigrationResult>; abstract setWithDerivedData(getData: SetDataGetter<AppModelType, DbModelType>): Promise<MigrationResult>; abstract update(data: firestore.UpdateData<DbModelType>, precondition?: firestore.Precondition): Promise<MigrationResult>; abstract update(field: string | firestore.FieldPath, value: any, ...moreFieldsOrPrecondition: any[]): Promise<MigrationResult>; abstract updateWithDerivedData(getData: UpdateDataGetter<AppModelType, DbModelType>, precondition?: firestore.Precondition): Promise<MigrationResult>; abstract updateWithDerivedData(getData: UpdateFieldValueGetter<AppModelType, DbModelType>): Promise<MigrationResult>; }