Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add relation options to all tree queries (#8080)
* feat: add relation options to all tree queries Closes: #8076 * fix: corrected array index in test case * try to fix failing test * fix: sort the array in order to be able to apply tests
- Loading branch information
1 parent
19d4a91
commit e4d4636
Showing
7 changed files
with
444 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { BaseEntity, Column, Entity, OneToMany, PrimaryGeneratedColumn, Tree, TreeChildren, TreeParent } from "../../../../src"; | ||
import { Site } from "./Site"; | ||
import { Member } from "./Member"; | ||
|
||
@Entity() | ||
@Tree("materialized-path") | ||
export class Category extends BaseEntity { | ||
|
||
@PrimaryGeneratedColumn() | ||
pk: number; | ||
|
||
@Column({ | ||
length: 250, | ||
nullable: false | ||
}) | ||
title: string; | ||
|
||
@TreeParent() | ||
parentCategory: Category | null; | ||
|
||
@TreeChildren() | ||
childCategories: Category[]; | ||
|
||
@OneToMany(() => Site, site => site.parentCategory) | ||
sites: Site[]; | ||
|
||
@OneToMany(() => Member, m => m.category) | ||
members: Member[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "../../../../src"; | ||
import { Category } from "./Category"; | ||
|
||
@Entity() | ||
export class Member extends BaseEntity { | ||
|
||
@PrimaryGeneratedColumn() | ||
pk: number; | ||
|
||
@Column({ | ||
length: 250, | ||
nullable: false | ||
}) | ||
title: string; | ||
|
||
@ManyToOne(() => Category, c => c.members) | ||
category: Category; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BaseEntity, Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from "../../../../src"; | ||
import { Category } from "./Category"; | ||
|
||
@Entity() | ||
export class Site extends BaseEntity { | ||
|
||
@PrimaryGeneratedColumn() | ||
pk: number; | ||
|
||
@CreateDateColumn() | ||
createdAt: Date; | ||
|
||
@Column({ | ||
length: 250, | ||
nullable: false | ||
}) | ||
title: string; | ||
|
||
@ManyToOne(() => Category) | ||
parentCategory: Category; | ||
} |
Oops, something went wrong.