UNPKG

typeorm

Version:

Data-Mapper ORM for TypeScript and ES2023+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.

80 lines (79 loc) 2.66 kB
import type { ObjectLiteral } from "../common/ObjectLiteral"; import type { FindTreeOptions } from "../find-options/FindTreeOptions"; import type { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder"; import { Repository } from "./Repository"; /** * Repository with additional functions to work with trees. * * @see Repository */ export declare class TreeRepository<Entity extends ObjectLiteral> extends Repository<Entity> { /** * Gets complete trees for all roots in the table. * * @param options */ findTrees(options?: FindTreeOptions): Promise<Entity[]>; /** * Roots are entities that have no ancestors. Finds them all. * * @param options */ findRoots(options?: FindTreeOptions): Promise<Entity[]>; /** * Gets all children (descendants) of the given entity. Returns them all in a flat array. * * @param entity * @param options */ findDescendants(entity: Entity, options?: FindTreeOptions): Promise<Entity[]>; /** * Gets all children (descendants) of the given entity. Returns them in a tree - nested into each other. * * @param entity * @param options */ findDescendantsTree(entity: Entity, options?: FindTreeOptions): Promise<Entity>; /** * Gets number of descendants of the entity. * * @param entity */ countDescendants(entity: Entity): Promise<number>; /** * Creates a query builder used to get descendants of the entities in a tree. * * @param alias * @param closureTableAlias * @param entity */ createDescendantsQueryBuilder(alias: string, closureTableAlias: string, entity: Entity): SelectQueryBuilder<Entity>; /** * Gets all parents (ancestors) of the given entity. Returns them all in a flat array. * * @param entity * @param options */ findAncestors(entity: Entity, options?: FindTreeOptions): Promise<Entity[]>; /** * Gets all parents (ancestors) of the given entity. Returns them in a tree - nested into each other. * * @param entity * @param options */ findAncestorsTree(entity: Entity, options?: FindTreeOptions): Promise<Entity>; /** * Gets number of ancestors of the entity. * * @param entity */ countAncestors(entity: Entity): Promise<number>; /** * Creates a query builder used to get ancestors of the entities in the tree. * * @param alias * @param closureTableAlias * @param entity */ createAncestorsQueryBuilder(alias: string, closureTableAlias: string, entity: Entity): SelectQueryBuilder<Entity>; }