firewalk
Version:
A collection traversal library for Firestore
33 lines (32 loc) • 2.67 kB
TypeScript
import type { firestore } from 'firebase-admin';
import type { BatchCallback, MigrationPredicate, MigrationResult, Migrator, SetDataGetter, SetOptions, SetPartialDataGetter, Traverser, UpdateDataGetter, UpdateFieldValueGetter } from '../../../api';
export type RegisteredCallbacks<D> = {
onBeforeBatchStart?: BatchCallback<D>;
onAfterBatchComplete?: BatchCallback<D>;
};
export declare abstract class AbstractMigrator<D> implements Migrator<D> {
protected readonly registeredCallbacks: RegisteredCallbacks<D>;
protected readonly migrationPredicates: MigrationPredicate<D>[];
protected constructor(registeredCallbacks?: RegisteredCallbacks<D>, migrationPredicates?: MigrationPredicate<D>[]);
protected get firestoreInstance(): firestore.Firestore;
protected get firestoreConstructor(): typeof firestore;
onBeforeBatchStart(callback: BatchCallback<D>): void;
onAfterBatchComplete(callback: BatchCallback<D>): 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<D>[]) => Promise<number>): Promise<MigrationResult>;
protected shouldMigrateDoc(doc: firestore.QueryDocumentSnapshot<D>): boolean;
abstract readonly traverser: Traverser<D>;
abstract withPredicate(predicate: MigrationPredicate<D>): Migrator<D>;
abstract withTraverser(traverser: Traverser<D>): Migrator<D>;
abstract set(data: firestore.PartialWithFieldValue<D>, options: SetOptions): Promise<MigrationResult>;
abstract set(data: firestore.WithFieldValue<D>): Promise<MigrationResult>;
abstract setWithDerivedData(getData: SetPartialDataGetter<D>, options: SetOptions): Promise<MigrationResult>;
abstract setWithDerivedData(getData: SetDataGetter<D>): Promise<MigrationResult>;
abstract update<D>(data: firestore.UpdateData<D>, precondition?: firestore.Precondition): Promise<MigrationResult>;
abstract update(field: string | firestore.FieldPath, value: any, ...moreFieldsOrPrecondition: any[]): Promise<MigrationResult>;
abstract updateWithDerivedData(getData: UpdateDataGetter<D>, precondition?: firestore.Precondition): Promise<MigrationResult>;
abstract updateWithDerivedData(getData: UpdateFieldValueGetter<D>): Promise<MigrationResult>;
}