/** * Many-to-many relationship builder for `@atlex/orm`. * * Extends `RelationBuilder` with pivot-table operations like attach/detach/sync * and pivot filtering/selection helpers. */ import type { Model } from '../Model.js'; import type { QueryBuilder } from '../QueryBuilder.js'; import type { PivotData } from '../types.js'; import { RelationBuilder, type RelationMeta } from './RelationBuilder.js'; interface SyncResult { attached: (number | string)[]; detached: (number | string)[]; updated: (number | string)[]; } export declare class ManyToManyRelationBuilder extends RelationBuilder { private pivotColumns; private pivotTimestamps; private pivotWheres; private pivotOrders; constructor(query: QueryBuilder, meta: RelationMeta); /** * Include pivot columns in the result set. They will be hydrated onto `model.pivot`. * * @param columns - Pivot columns to include. * @returns this * @example * user.roles().withPivot('assigned_at') */ withPivot(...columns: string[]): this; /** * Include `created_at` and `updated_at` from the pivot table. * * @returns this * @example * user.roles().withTimestamps() */ withTimestamps(): this; /** * Add a pivot WHERE constraint. */ wherePivot(column: string, operator: string, value: unknown): this; /** * Add a pivot ORDER BY constraint. */ orderByPivot(column: string, direction?: 'asc' | 'desc'): this; /** * Attach related ids to the parent via the pivot table. * * @param ids - Related id or ids. * @param pivotData - Additional pivot columns. * @returns void * @example * await user.roles().attach([1,2], { assigned_at: new Date() }) */ attach(ids: number | string | (number | string)[], pivotData?: PivotData): Promise; /** * Detach related ids (or all when none provided). */ detach(ids?: (number | string)[]): Promise; /** * Sync related ids against the pivot. */ sync(ids: (number | string)[], detaching?: boolean): Promise; syncWithoutDetaching(ids: (number | string)[]): Promise; toggle(ids: (number | string)[]): Promise; updateExistingPivot(id: number | string, data: PivotData): Promise; } export {}; //# sourceMappingURL=ManyToManyRelationBuilder.d.ts.map