UNPKG

@warlock.js/cascade

Version:

ORM for managing databases

73 lines 2.09 kB
import type { ModelAggregate } from "./ModelAggregate"; import type { Model } from "./model"; import type { CascadeOnDelete } from "./types"; export declare class ModelSync { protected model: typeof Model; protected columns: string | string[]; protected embedMethod: string; /** * What do do when model is deleted */ protected whenDelete: CascadeOnDelete; /** * Embed on create */ protected embedOnCreate: string; /** * Sync mode */ protected syncMode: "single" | "many"; /** * Query runner using `when` method */ protected queryRunner?: (query: ModelAggregate<Model>) => void; /** * Define when should the synced model starts to update when any of the given columns is updated in the original model */ protected _updateWhenChange?: string[]; /** * Constructor */ constructor(model: typeof Model, columns: string | string[], embedMethod?: string); /** * Define when should the synced model starts to update when any of the given columns is updated in the original model */ updateWhenChange(columns: string | string[]): this; /** * Set query runner */ where(queryRunner: (query: ModelAggregate<Model>) => void): this; /** * Unset on delete */ unsetOnDelete(): this; /** * Ignore on delete */ ignoreOnDelete(): this; /** * Remove all matched documents on delete to be fully deleted */ removeOnDelete(): this; /** * Embed on create to injected model one the original model is created */ embedOnCreateFrom(column: string): this; /** * Mark as many sync */ syncMany(): this; /** * Start syncing the model */ sync(model: Model, saveMode: "create" | "update", oldModel?: Model): Promise<void>; /** * Sync update */ syncUpdate(model: Model, oldModel?: Model): Promise<void>; /** * Sync model destruction */ syncDestruction(model: Model): Promise<void>; } //# sourceMappingURL=ModelSync.d.ts.map