import { BaseRelation } from './base_relation.js'; import type { MongoModel, MongoModelConstructor } from '../model/base_model.js'; import { ObjectId } from 'mongodb'; /** * BelongsToMany relationship for MongoDB * Handles many-to-many relationships through a pivot collection */ export declare class BelongsToMany extends BaseRelation { /** * The pivot model */ protected pivotModel: MongoModelConstructor; /** * The foreign key on the pivot model that references the owner model */ protected pivotForeignKey: string; /** * The foreign key on the pivot model that references the related model */ protected pivotRelatedKey: string; constructor(relatedModel: MongoModelConstructor, ownerModel: MongoModel, pivotModel: MongoModelConstructor, pivotForeignKey?: string, pivotRelatedKey?: string, localKey?: string, relatedKey?: string); /** * Set up the relationship */ setup(): Promise; /** * Execute the relation query to get related models through the pivot */ exec(): Promise; /** * Attach one or more related models to the owner model */ attach(ids: string[] | ObjectId[]): Promise; /** * Attach related models with additional pivot data */ attachWithPivotData(data: { id: string | ObjectId; pivotData?: Record; }[]): Promise; /** * Detach one or more related models from the owner model */ detach(ids?: string[] | ObjectId[]): Promise; /** * Sync the relationship by detaching all existing relations and attaching the given IDs */ sync(ids: string[] | ObjectId[]): Promise; /** * Sync the relationship with pivot data */ syncWithPivotData(data: { id: string | ObjectId; pivotData?: Record; }[]): Promise; /** * Check if a relationship exists between the owner and the given related ID */ exists(id: string | ObjectId): Promise; /** * Get pivot data for a specific relation */ pivotData(id: string | ObjectId): Promise | null>; /** * Update pivot data for a specific relation */ updatePivotData(id: string | ObjectId, data: Record): Promise; }