UNPKG

@360-l/mongo-bulk-data-migration

Version:
38 lines (37 loc) 1.6 kB
import type { BulkOperationResult } from './lib/AbstractBulkOperationResults'; import type { DataMigrationConfig, LoggerInterface, MigrationInfos, RollbackableUpdate } from './types'; import type { Collection, Document, Filter } from 'mongodb'; export declare const DELETE_COLLECTION: unique symbol; export declare const FETCH_ALL: unique symbol; export default class MongoBulkDataMigration<TSchema extends Document, TQuery extends Filter<TSchema> | typeof FETCH_ALL = Filter<TSchema>> implements RollbackableUpdate { private readonly options; private readonly collectionName; private readonly id; private readonly migrationInfos; private logger; constructor(...args: [keyof TQuery] extends [never] ? ['Use FETCH_ALL instead of an empty query {}'] : [config: DataMigrationConfig<TSchema, TQuery>]); setLogger(logger: LoggerInterface): void; getInfos(): { id: string; migrationInfos: MigrationInfos<TSchema>; collection: Collection<TSchema>; collectionName: string; }; private getRollbackCollection; private getRollbackCollectionName; private getCollection; update(): Promise<BulkOperationResult>; private getCursorAndCount; private buildBulkUpdater; private buildBackupDocument; private throttle; private resolveQuery; rollback(): Promise<BulkOperationResult>; private getRollbackUpdateQuery; private lowerValidationLevel; private restoreValidationLevel; private canUpdateValidation; private setValidationLevel; private renameCollection; clean(): Promise<void>; }