adonis-odm
Version:
A comprehensive MongoDB ODM for AdonisJS with Lucid-style API, type-safe relationships, embedded documents, and transaction support
61 lines • 2.15 kB
TypeScript
/**
* SEAMLESS RELATIONSHIP PROXIES - LIKE ADONISJS LUCID!
*
* This module implements advanced JavaScript Proxy patterns to achieve seamless
* property access for relationships, exactly like AdonisJS Lucid.
*
* Key Features:
* - Direct property access: user.profile.firstName
* - Array access for HasMany: user.posts[0].title
* - Transparent method forwarding
* - Zero developer overhead
* - Full TypeScript IntelliSense support
*/
import type { BaseModel } from '../base_model/base_model.js';
import type { HasOne, HasMany, BelongsTo } from '../types/relationships.js';
/**
* SEAMLESS HASONE PROXY
*
* Creates a proxy that transparently forwards property access to the related model
* when loaded, providing seamless access like: user.profile.firstName
*/
export declare function createHasOneProxy<T extends typeof BaseModel>(relatedModel: () => T, _options?: {
foreignKey?: string;
localKey?: string;
}): HasOne<T>;
/**
* SEAMLESS HASMANY PROXY
*
* Creates a proxy that provides array-like access and seamless property forwarding
* for HasMany relationships, like: user.posts[0].title
*/
export declare function createHasManyProxy<T extends typeof BaseModel>(relatedModel: () => T, _options?: {
foreignKey?: string;
localKey?: string;
}): HasMany<T>;
/**
* SEAMLESS BELONGSTO PROXY
*
* Creates a proxy that transparently forwards property access to the related model
* when loaded, providing seamless access like: post.author.name
*/
export declare function createBelongsToProxy<T extends typeof BaseModel>(relatedModel: () => T, _options?: {
foreignKey?: string;
localKey?: string;
}): BelongsTo<T>;
/**
* PROXY FACTORY FUNCTIONS
*
* These functions create the appropriate proxy based on relationship type
*/
/**
* Create a relationship proxy based on metadata
*/
export declare function createRelationshipProxy(type: 'hasOne' | 'hasMany' | 'belongsTo', relatedModel: () => typeof BaseModel, options?: {
foreignKey?: string;
localKey?: string;
}): HasOne<any> | HasMany<any> | BelongsTo<any>;
/**
* SEAMLESS TYPE SAFETY EXPORTS
*/
//# sourceMappingURL=relationship_proxies.d.ts.map