import { Client, Doc, DocumentQuery, Domain, FindOptions, Hierarchy, IncOptions, ModelDb, ObjQueryType, PushOptions, Ref, UnsetOptions } from '@hcengineering/core' /** * @public */ export type MigrateUpdate = Partial & Omit, '$move'> & IncOptions & UnsetOptions & { // For any other mongo stuff [key: string]: any } /** * @public */ export interface MigrationResult { matched: number updated: number } /** * @public */ export type MigrationDocumentQuery = { [P in keyof T]?: ObjQueryType | null } & { $search?: string // support nested queries e.g. 'user.friends.name' // this will mark all unrecognized properties as any (including nested queries) [key: string]: any } /** * @public * Client to perform model upgrades */ export interface MigrationClient { // Raw collection operations // Raw FIND, allow to find documents inside domain. find: ( domain: Domain, query: MigrationDocumentQuery, options?: Omit, 'lookup'> ) => Promise // Allow to raw update documents inside domain. update: ( domain: Domain, query: MigrationDocumentQuery, operations: MigrateUpdate ) => Promise bulk: ( domain: Domain, operations: { filter: MigrationDocumentQuery, update: MigrateUpdate }[] ) => Promise // Move documents per domain move: (sourceDomain: Domain, query: DocumentQuery, targetDomain: Domain) => Promise create: (domain: Domain, doc: T) => Promise delete: (domain: Domain, _id: Ref) => Promise hierarchy: Hierarchy model: ModelDb } /** * @public */ export type MigrationUpgradeClient = Client /** * @public */ export interface MigrateOperation { // Perform low level migration migrate: (client: MigrationClient) => Promise // Perform high level upgrade operations. upgrade: (client: MigrationUpgradeClient) => Promise }