import { Entity } from './Entity'; import { EntityConstructor, EntityMetadata, EntityObject, ID, Query } from './index'; import { List } from './List'; import { BaseRelationship } from './ORM/BaseRelationship'; import { EntityQuery } from './EntityQuery'; export interface EntityField { value(entity: T, key: string): T[K] | T[K][] | string | number | undefined; set(entity: T, key: T[K]): void; } export declare class ColumnField implements EntityField { entity: EntityConstructor; property: string; type: () => Function; column: string; constructor(entity: EntityConstructor, property: string, type: () => Function, column: string); value(entity: T, key: string): T[K] | T[K][] | string | number | undefined; set(target: T, value: T[keyof T]): void; } export declare class JSONField extends ColumnField { value(entity: T, key: string): T[K] | T[K][] | string | number | undefined; set(target: T, value: T[keyof T]): void; } export declare abstract class InverseField implements EntityField { entity: EntityConstructor; property: string; type: () => Function; protected constructor(entity: EntityConstructor, property: string, type: () => Function); value(entity: T, key: string): T[K] | T[K][] | string | number | undefined; abstract set(target: T, value: T[keyof T]): void; } export declare class PrimaryField extends ColumnField { } export declare abstract class RelationshipField extends ColumnField { type: () => EntityConstructor; inverseBy: string; abstract relationClass: typeof BaseRelationship; protected constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string, column: string); get related(): EntityConstructor; abstract match(entities: T[], relatedEntities: R[]): T[]; abstract matchCounts(entities: T[], counts: T[]): T[]; abstract getRelatedValue(relatedEntities: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; abstract getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; abstract update(target: T): void; } export declare abstract class InverseRelationship extends InverseField { type: () => EntityConstructor; inverseBy: string; abstract relationClass: typeof BaseRelationship; protected constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string); get related(): EntityConstructor; abstract match(entities: T[], relatedEntities: R[]): T[]; abstract matchCounts(entities: T[], counts: T[]): T[]; abstract getRelatedValue(relatedEntities: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; abstract getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; } export declare class HasOneField extends InverseRelationship { relationClass: typeof HasOne; constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string); set(target: T, value: T[keyof T]): void; getRelatedValue(relatedEntities: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; match(entities: T[], relatedEntities: R[]): T[]; matchCounts(entities: T[], counts: T[]): T[]; } export declare class HasManyField extends InverseRelationship { inverseBy: string; relationClass: typeof HasMany; constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string); set(target: T, value: T[keyof T]): void; getRelatedValue(relatedEntities: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; match(entities: T[], relatedEntities: R[]): T[]; matchCounts(entities: T[], counts: T[]): T[]; save(items: Partial | R>[], parent: T): Promise; getQuery(parent: T): EntityQuery; } export declare class BelongsToField extends RelationshipField { relationClass: typeof BelongsTo; constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string, column?: string); set(target: T, value: T[keyof T]): void; update(target: T): void; value(entity: T, key: string): undefined; getRelatedValue(parents: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; match(entities: T[], relatedEntities: R[]): T[]; matchCounts(entities: T[], counts: T[]): T[]; getQuery(parent: T): EntityQuery; save(items: Partial | R>[], parent: T): Promise; } export declare class BelongsToManyField extends InverseRelationship { table?: string | undefined; parentColumn?: string | undefined; relatedColumn?: string | undefined; relationClass: typeof BelongsToMany; constructor(entity: EntityConstructor, property: string, type: () => EntityConstructor, inverseBy: string, table?: string | undefined, parentColumn?: string | undefined, relatedColumn?: string | undefined); set(target: T, value: T[keyof T]): void; getRelatedValue(parents: R[], eagerLoad: EntityQuery['eagerLoad'], customQuery?: (query: Query) => void): Promise; getParentForeignKey(): string; getRelatedForeignKey(): string; getRelatedCount(relatedEntities: R[], customQuery?: (query: Query) => void): Promise; match(entities: T[], relatedEntities: R[]): T[]; matchCounts(entities: T[], counts: T[]): T[]; getPivotTable(): string; value(entity: T, key: string): T[K]; add(items: (R | ID)[], parent: T): Promise; getQuery(parent: T): EntityQuery; } export interface EntityFieldOptions { table?: string; column?: string; } export interface BelongsToManyFieldOptions extends EntityFieldOptions { foreignColumn?: string; } export declare class BelongsTo extends BaseRelationship { private instance?; constructor(relationship: RelationshipField, parent: P); update(): void; static relationship(metadata: EntityMetadata, entityClass: EntityConstructor, property: keyof T, type: () => EntityConstructor, inverseBy: keyof R, options?: EntityFieldOptions): EntityMetadata; get(): T | undefined; set(instance: T | number): void; setById(id: number): void; save(data?: EntityObject | {} | undefined): Promise; toJSON(): { [K in keyof T]: T[K]; } | undefined; } export declare class HasOne extends BaseRelationship { relationship: RelationshipField; private instance?; static relationship(metadata: EntityMetadata, entityClass: EntityConstructor, property: keyof T, type: () => EntityConstructor, inverseBy: keyof R, options?: EntityFieldOptions): EntityMetadata; get(): T | undefined; set(instance: T | number | undefined): void; setById(id: number): void; save(instance?: T | undefined): Promise; toJSON(): { [K in keyof T]: T[K]; } | undefined; } export declare class HasMany extends List { relationship: HasManyField; constructor(relationship: HasManyField, parent: P); static relationship(metadata: EntityMetadata, entityClass: EntityConstructor, property: keyof T, type: () => EntityConstructor, inverseBy: keyof R, options?: EntityFieldOptions): EntityMetadata; save(item: Partial | T>): Promise; saveMany(...items: Partial | T>[]): Promise; clear(): Promise; } export declare class BelongsToMany extends List { relationship: BelongsToManyField; constructor(relationship: BelongsToManyField, parent: P); static relationship(metadata: EntityMetadata, entityClass: EntityConstructor, property: keyof T, type: () => EntityConstructor, inverseBy: keyof R, options?: BelongsToManyFieldOptions): EntityMetadata; has(item: T | ID): Promise; add(...items: (T | ID)[]): Promise; remove(...items: (T | ID)[]): Promise; toggle(...items: (T | ID)[]): Promise; clear(): Promise; sync(...items: (T | ID)[]): Promise; syncWithoutDetaching(...items: (T | ID)[]): Promise; } //# sourceMappingURL=Fields.d.ts.map