import { ObjectId } from './objectid'; export declare class VirtualType { private _getter?; private _setter?; get(fn: ((this: any) => T) | ((doc: any) => T)): this; set(fn: ((this: any, value: T) => void) | ((doc: any, value: T) => void)): this; applyGetter(doc: any): T | undefined; applySetter(doc: any, value: T): void; hasSetter(): boolean; } export type SaveHookContext = { doc: T; }; export type PreDeleteHookContext> = { query: Record; _?: T; }; export type PostDeleteHookContext = { query: Record; deletedCount: number; docs?: T[]; }; export type DeleteHookContext = PreDeleteHookContext | PostDeleteHookContext; export type PreUpdateHookContext = { query: Record; update?: Record; doc?: T; }; export type PostUpdateHookContext = { query: Record; update?: Record; modifiedCount: number; docs?: T[]; }; export type UpdateHookContext = PreUpdateHookContext | PostUpdateHookContext; export type PreFindHookContext> = { query: Record; _?: T; }; export type PostFindHookContext = { query: Record; result?: T | null; results?: T[]; }; export type FindHookContext = PreFindHookContext | PostFindHookContext; export type HookFunction = (context: Record) => void | Promise; export type ValidatorFunction = (value: unknown) => boolean | Promise; export type FieldOptions = { type?: any; required?: boolean | [boolean, string]; default?: any | (() => any); min?: number | [number, string]; max?: number | [number, string]; minLength?: number | [number, string]; maxLength?: number | [number, string]; enum?: any[] | { values: any[]; message?: string; }; match?: RegExp | [RegExp, string]; validate?: ValidatorFunction | { validator: ValidatorFunction; message?: string; }; ref?: string; get?: (value: any) => any; set?: (value: any) => any; unique?: boolean; }; export declare class ValidationError extends Error { constructor(message: string); } export declare class DuplicateKeyError extends Error { code: number; keyPattern: Record; keyValue: Record; constructor(fields: string[], values?: Record); } export type SearchIndexDescriptor = { name?: string; type?: 'search' | 'vectorSearch'; definition: Record; }; export type SchemaOptions = { timestamps?: boolean | { createdAt?: string | boolean; updatedAt?: string | boolean; }; discriminatorKey?: string; autoSearchIndex?: boolean; }; export declare class Schema> { static Types: { ObjectId: typeof ObjectId; }; private _definition; private _fieldOptions; private _indexes; private _uniqueIndexes?; private _ttlIndexes; private _virtuals; private _preHooks; private _postHooks; private _options; private _searchIndexes; methods: Record any>; statics: Record any>; constructor(definition: Record, options?: SchemaOptions); private _parseFieldDefinitions; index(fields: keyof T | Array | Record, options?: { unique?: boolean; ttl?: number; }): this; virtual(name: string): VirtualType; getIndexes(): Array>; searchIndex(desc: SearchIndexDescriptor): this; getSearchIndexes(): ReadonlyArray; getUniqueIndexes(): Set; getTTLIndexes(): Map; getVirtuals(): Map; pre(event: 'save', fn: (context: SaveHookContext) => void | Promise): this; pre(event: 'delete', fn: (context: PreDeleteHookContext) => void | Promise): this; pre(event: 'update', fn: (context: PreUpdateHookContext) => void | Promise): this; pre(event: 'find' | 'findOne', fn: (context: PreFindHookContext) => void | Promise): this; post(event: 'save', fn: (context: SaveHookContext) => void | Promise): this; post(event: 'delete', fn: (context: PostDeleteHookContext) => void | Promise): this; post(event: 'update', fn: (context: PostUpdateHookContext) => void | Promise): this; post(event: 'find' | 'findOne', fn: (context: PostFindHookContext) => void | Promise): this; getPreHooks(event: string): HookFunction[]; getPostHooks(event: string): HookFunction[]; getFieldOptions(fieldName: keyof T): FieldOptions | undefined; getAllFieldOptions(): Map; applyGetters(doc: any): any; applySetters(doc: any): void; applyDefaults(doc: any): void; getOptions(): SchemaOptions; getTimestampConfig(): { createdAt: string; updatedAt: string; } | null; /** * Load methods, statics, and virtuals from a class into the schema. * Instance methods (non-static methods) are added to schema.methods * Static methods are added to schema.statics * Getters and setters are added as virtuals * * @param classConstructor - The class to load methods from * @returns this for chaining */ loadClass(classConstructor: new (...args: any[]) => any): this; validate(doc: Partial): Promise; /** * Serialize schema to a JSON-compatible format for storage tracking * This allows schema versions to be recorded and compared */ toJSON(): { definition: Record; indexes: Array<{ fields: string[]; unique: boolean; }>; options: SchemaOptions; version: string; }; } //# sourceMappingURL=schema.d.ts.map