UNPKG

adonis-odm

Version:

A comprehensive MongoDB ODM for AdonisJS with Lucid-style API, type-safe relationships, embedded documents, and transaction support

96 lines 2.62 kB
import type { BaseModel } from '../base_model/base_model.js'; import { EmbeddedQueryBuilder } from './embedded_query_builder.js'; /** * Proxy for single embedded documents with full CRUD capabilities * Returns an EmbeddedModelInstance that behaves exactly like a regular model */ export declare class EmbeddedSingleProxy<T extends typeof BaseModel> { private _value; private _parent; private _fieldName; private _modelClass; constructor(parent: BaseModel, fieldName: string, modelClass: T, initialValue?: any); /** * Set the embedded value */ setValue(value: any): void; /** * Get the embedded value */ getValue(): any; /** * Create a new embedded instance */ create(attributes: Partial<InstanceType<T>>): any; /** * Clear the embedded value */ clear(): void; /** * Mark parent model as dirty */ private markParentDirty; /** * Serialize for database storage */ toDocument(): any; } /** * Proxy for multiple embedded documents with full CRUD capabilities * Returns an array where each item is an EmbeddedModelInstance */ export declare class EmbeddedManyProxy<T extends typeof BaseModel> extends Array { private _parent; private _fieldName; private _modelClass; constructor(parent: BaseModel, fieldName: string, modelClass: T, initialValue?: any[]); /** * Set the items array */ setItems(items: any[]): void; /** * Query the embedded documents */ query(): EmbeddedQueryBuilder<T>; /** * Create a new embedded document */ create(attributes: Partial<InstanceType<T>>): any; /** * Create multiple embedded documents */ createMany(attributesArray: Partial<InstanceType<T>>[]): any[]; /** * Remove an embedded document */ remove(item: any): boolean; /** * Remove embedded documents by condition */ removeWhere(callback: (item: any) => boolean): number; /** * Override push to maintain array indices */ push(...items: any[]): number; /** * Override pop to maintain array indices */ pop(): any; /** * Override splice to maintain array indices */ splice(start: number, deleteCount?: number, ...items: any[]): any[]; /** * Update array indices for all items */ private updateArrayIndices; /** * Mark parent model as dirty */ private markParentDirty; /** * Serialize for database storage */ toDocument(): any[]; } //# sourceMappingURL=embedded_proxies.d.ts.map