import { FetchRelations, RelationKeyOf } from '.'; import { Condition, DefaultRowObject, XTable } from '../core'; import { DbContext } from './db-context'; import { Entity, EntityConstructor, EntityInstance, EntityKeyType } from './entity'; import { ColumnMetadata, ForeignOneToOneMetadata, ManyToManyMetadata, ManyToOneMetadata, OneToManyMetadata, OneToOneMetadata, RelationMetadata } from './metadata'; import { DataType } from './data-types'; /** * 实体管理器 * - 用于转换数据库类型与实体类型 * - 以及导航属性的关联查询 * 内部类型,请不要使用 */ export declare class EntityMgr { private context; constructor(entityCtr: EntityConstructor, context: DbContext); private metadata; /** * 转换成数据库所使用的值 */ toDbValue(item: T, column: ColumnMetadata): any; /** * 将EntityInstance 转换为 DataRow */ toDataRow(item: T, datarow?: DefaultRowObject): DefaultRowObject; /** * 转换成实体属性值 */ toEntityValue(datarow: DefaultRowObject, column: ColumnMetadata): any; /** * 获取插入信息 */ getInsertValues(rowset: XTable, item: T): Promise; /** * 获取更新信息 */ getUpdateChanges(rowset: XTable, item: T): Promise; /** * 获取定位查询条件(仅查询) * @param item * @returns */ getQueryWhere(rowset: XTable, item: T): Condition; getUpdateWhere(rowset: XTable, item: T): Condition; getKey(item: T): EntityKeyType; _toDataType(value: any, type: DataType): any; /** * 将数据库记录转换为实体实例 */ toEntity(datarow: DefaultRowObject, item?: T): EntityInstance; getKeyValue(item: EntityInstance | T): EntityKeyType; private _loaders?; private get loaders(); /** * 通过外键获取项 */ fetchByForeignKey(relation: ManyToOneMetadata | ForeignOneToOneMetadata, fkValue: EntityKeyType, options?: { includes?: FetchRelations; }): Promise; /** * 通过主键获取项 */ fetchByKey(keyValue: EntityKeyType, options?: { includes?: FetchRelations; }): Promise>; private fetchByManyToManyKey; private queryable; /** * 向实体实例加载导航属性 */ loadRelations(items: T[], relations: FetchRelations, options?: { /** * 是否强制加载已存在的关联关系,如果为false,则已存在属性不会被再次加载 */ force?: boolean; }): Promise; /** * 获取明细属性,但不改变原实体。 * 无论实体是否已存在该属性,均会从数据库获取 */ fetchRelation>(items: T[], relation: ManyToManyMetadata | OneToManyMetadata, options?: { includes?: FetchRelations; }): Promise; fetchRelation>(items: T[], relations: OneToOneMetadata | ManyToOneMetadata, options?: { includes?: FetchRelations; }): Promise; fetchRelation>(items: T[], relation: RelationMetadata, options?: { includes?: FetchRelations; }): Promise; }