-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[ ] question
[ ] bug report
[ ] feature request
[x] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
The example for the 'adjacency-list' tree entity documentation doesn't work (http://typeorm.io/#/tree-entities/adjacency-list).
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToMany} from "typeorm";
@Entity()
export class Category {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
description: string;
@ManyToOne(type => Category, category => category.children)
parent: Category;
@OneToMany(type => Category, category => category.parent)
children: Category[];
}
...
manager.getTreeRepository(Category).findTrees();It gives the following error
RepositoryNotTreeError: Repository of the "Category" class is not a TreeRepository. Try to apply @Tree decorator on your entity.
Adding the Tree decorator results in another error
...
@Entity()
@Tree("adjacency-list")
export class Category {
...Cannot read property 'propertyName' of undefined.
Adding TreeChildren and TreeParent results in another error
@Entity()
@Tree("adjacency-list")
export class Category {
@PrimaryGeneratedColumn() id: number
@Column() name: string
@ManyToOne(type => Category, category => category.children)
@TreeParent()
parent: Category
@OneToMany(type => Category, category => category.parent)
@TreeChildren()
children: Category[]
}Error: Supported only in tree entities