import { ObjectId } from "mongodb"; import { RelationshipModel } from "./relationships"; import { CastType, Casts, CustomCasts, Document } from "./types"; export type Schema = Record & { _id?: ObjectId; id?: number; createdAt?: Date; updatedAt?: Date; }; export declare class Model extends RelationshipModel { /** * Model Initial Document data */ initialData: Partial; /** * Model Document data */ data: Schema; /** * Define Default value data that will be merged with the models' data * on the create process */ defaultValue: Partial; /** * A flag to determine if the model is being restored */ protected isRestored: boolean; /** * Model casts types */ protected casts: Casts; /** * Set custom casts that will be used to cast the model's data are not related to the current value of the collection's column * * For example: `name` is not a column in the given data, but it will be concatenation of `firstName` and `lastName` */ protected customCasts: CustomCasts; /** * Guarded fields */ guarded: string[]; /** * Fillable fields */ filled: string[]; /** * Embedded columns */ embedded: string[]; /** * Embed all columns except the given columns */ embedAllExcept: string[]; /** * Embed all columns except timestamps and created|updated|deleted by columns */ embedAllExceptTimestampsAndUserColumns: boolean; /** * Created at column */ createdAtColumn: string; /** * Updated at column */ updatedAtColumn: string; /** * Deleted at column */ deletedAtColumn: string; /** * Created by column */ createdByColumn: string; /** * Updated by column */ updatedByColumn: string; /** * Deleted by column */ deletedByColumn: string; /** * Date format */ dateFormat: string; /** * A flag to determine if the id is auto generated not added manually */ protected autoGeneratedId: boolean; /** * Is active column */ protected isActiveColumn: string; /** * Original data */ originalData: Schema; /** * Constructor */ constructor(originalData?: Schema | Model); /** * Get save columns which are the casts keys */ get castColumns(): string[]; /** * Cast dates */ protected castDates(data: Schema): Schema; /** * Get value from original data */ original(key: string, defaultValue?: any): any; /** * Get all data except the guarded fields */ get publicData(): any; /** * Get guarded data */ get guardedData(): any; /** * Get the model's id */ get id(): number; /** * Check if current user is active */ get isActive(): boolean; /** * Get mongodb id */ get _id(): ObjectId; /** * Mark the current model as being restored */ markAsRestored(): void; /** * Set a column in the model data */ set(column: keyof Schema, value: any): this; /** * Increment the given column by the given value */ increment(column: keyof Schema, value?: number): this; /** * Decrement the given column by the given value */ decrement(column: keyof Schema, value?: number): this; /** * Get initial value of the given column */ getInitial(column: keyof Schema, defaultValue?: any): any; /** * Get value of the given column */ get(column: keyof Schema, defaultValue?: any): any; /** * Determine whether the given column exists in the document */ has(column: keyof Schema): boolean; /** * Get all columns except the given ones */ except(columns: (keyof Schema)[]): Document; /** * Get only the given columns */ only(columns: (keyof Schema)[]): Document; /** * Get only id */ get onlyId(): Document; /** * Unset or remove the given columns from the data */ unset(...columns: (keyof Schema)[]): this; /** * Replace the entire document data with the given new data */ replaceWith(data: Schema): this; /** * Merge the given documents to current document */ merge(data: Document): this; /** * Perform saving operation either by updating or creating a new record in database */ save(mergedData?: Omit, { triggerEvents, cast, forceUpdate, }?: { triggerEvents?: boolean; cast?: boolean; forceUpdate?: boolean; }): Promise; /** * Generate and return next id */ generateNextId(): Promise; /** * Perform saving but without any events triggers */ silentSaving(mergedData?: Omit, options?: { cast?: boolean; }): Promise; /** * Determine whether the model should be updated or not */ protected shouldUpdate(originalData: Schema, data: Schema): boolean; /** * Triggered before saving the model either by creating or updating */ protected onSaving(): Promise; /** * Triggered after saving the model either by creating or updating */ protected onSaved(): Promise; /** * Triggered before creating the model */ protected onCreating(): Promise; /** * Triggered after creating the model */ protected onCreated(): Promise; /** * Triggered before updating the model */ protected onUpdating(): Promise; /** * Triggered after updating the model */ protected onUpdated(): Promise; /** * Triggered before deleting the model */ protected onDeleting(): Promise; /** * Triggered after deleting the model */ protected onDeleted(): Promise; /** * Cast data before saving */ protected castData(forceUpdate?: boolean): Promise; /** * Cast the given value based on the given cast type */ protected castValue(value: any, castType: CastType): any; /** * Check for default values */ protected checkDefaultValues(): void; /** * Destroy the model and delete it from database collection */ destroy(): Promise; /** * Determine if the given column is dirty column * * Dirty columns are columns that their values have been changed from the original data */ isDirty(column?: string): boolean; /** * Check if current model is a new model */ isNewModel(): boolean; /** * Get embedded data */ get embeddedData(): any; /** * Clone the model */ clone(): this; } export type ModelType = typeof Model; //# sourceMappingURL=model.d.ts.map