Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/typeorm/src/index.ts>TreeRepository

Forked from https://github.com/typeorm/typeorm
Latest
class TreeRepository
extends Repository<Entity>
Re-export
import { TreeRepository } from "https://deno.land/x/typeorm@v0.2.23-rc10/src/index.ts";

Repository with additional functions to work with trees.

Methods

protected
buildChildrenEntityTree(
entity: any,
entities: any[],
relationMaps: { id: any; parentId: any; }[],
): void
protected
buildParentEntityTree(
entity: any,
entities: any[],
relationMaps: { id: any; parentId: any; }[],
): void
protected
createRelationMaps(alias: string, rawResults: any[]): { id: any; parentId: any; }[]

Moves entity to the children of then given entity.

move(entity: Entity, to: Entity): Promise<void> {
    return Promise.resolve();
}
countAncestors(entity: Entity): Promise<number>

Gets number of ancestors of the entity.

countDescendants(entity: Entity): Promise<number>

Gets number of descendants of the entity.

createAncestorsQueryBuilder(
alias: string,
closureTableAlias: string,
entity: Entity,
): SelectQueryBuilder<Entity>

Creates a query builder used to get ancestors of the entities in the tree.

createDescendantsQueryBuilder(
alias: string,
closureTableAlias: string,
entity: Entity,
): SelectQueryBuilder<Entity>

Creates a query builder used to get descendants of the entities in a tree.

findAncestors(entity: Entity): Promise<Entity[]>

Gets all parents (ancestors) of the given entity. Returns them all in a flat array.

findAncestorsTree(entity: Entity): Promise<Entity>

Gets all parents (ancestors) of the given entity. Returns them in a tree - nested into each other.

findDescendants(entity: Entity): Promise<Entity[]>

Gets all children (descendants) of the given entity. Returns them all in a flat array.

findDescendantsTree(entity: Entity): Promise<Entity>

Gets all children (descendants) of the given entity. Returns them in a tree - nested into each other.

findRoots(): Promise<Entity[]>

Roots are entities that have no ancestors. Finds them all.

findTrees(): Promise<Entity[]>

Gets complete trees for all roots in the table.

Methods

protected
buildChildrenEntityTree(
entity: any,
entities: any[],
relationMaps: { id: any; parentId: any; }[],
): void
protected
buildParentEntityTree(
entity: any,
entities: any[],
relationMaps: { id: any; parentId: any; }[],
): void
protected
createRelationMaps(alias: string, rawResults: any[]): { id: any; parentId: any; }[]

Moves entity to the children of then given entity.

move(entity: Entity, to: Entity): Promise<void> {
    return Promise.resolve();
}
countAncestors(entity: Entity): Promise<number>

Gets number of ancestors of the entity.

countDescendants(entity: Entity): Promise<number>

Gets number of descendants of the entity.

createAncestorsQueryBuilder(
alias: string,
closureTableAlias: string,
entity: Entity,
): SelectQueryBuilder<Entity>

Creates a query builder used to get ancestors of the entities in the tree.

createDescendantsQueryBuilder(
alias: string,
closureTableAlias: string,
entity: Entity,
): SelectQueryBuilder<Entity>

Creates a query builder used to get descendants of the entities in a tree.

findAncestors(entity: Entity): Promise<Entity[]>

Gets all parents (ancestors) of the given entity. Returns them all in a flat array.

findAncestorsTree(entity: Entity): Promise<Entity>

Gets all parents (ancestors) of the given entity. Returns them in a tree - nested into each other.

findDescendants(entity: Entity): Promise<Entity[]>

Gets all children (descendants) of the given entity. Returns them all in a flat array.

findDescendantsTree(entity: Entity): Promise<Entity>

Gets all children (descendants) of the given entity. Returns them in a tree - nested into each other.

findRoots(): Promise<Entity[]>

Roots are entities that have no ancestors. Finds them all.

findTrees(): Promise<Entity[]>

Gets complete trees for all roots in the table.