Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Tree Depth #3909

Closed
raydirty opened this issue Mar 27, 2019 · 2 comments · Fixed by #7926
Closed

Define Tree Depth #3909

raydirty opened this issue Mar 27, 2019 · 2 comments · Fixed by #7926

Comments

@raydirty
Copy link

Issue type:

[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] 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:

Linking to the official documentation about Trees.

Is it possible to limit the depth in a recursive tree hierarchy?

For example something like that:

const manager = getManager();
const trees = await manager.getTreeRepository(Category).findTrees({limit: 1});

and then the response would look like this:

[{
    "id": 1,
    "name": "a1",
    "children": [{
        "id": 2,
        "name": "a11"
    }, {
        "id": 3,
        "name": "a12"
    }]
}]

This could be helpful to "paginate" trees and to improve the performance of APIs.

@johanneslumpe
Copy link

I am also interested in this. Right now the closure table strategy does not store the tree depth in the table, so without code changes to how the strategy is implemented this probably isn't possible.

@guiaramos
Copy link

Any workaround for this?

tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Jul 17, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Jul 17, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Jul 17, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Aug 24, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Nov 3, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
tiagojsag added a commit to tiagojsag/typeorm that referenced this issue Nov 11, 2021
…using TreeRepository's findTrees() and findDescendantsTree()

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
pleerock pushed a commit that referenced this issue Nov 11, 2021
…using TreeRepository's findTrees() and findDescendantsTree() (#7926)

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: #3909
HeartPattern pushed a commit to HeartPattern/typeorm that referenced this issue Nov 29, 2021
…using TreeRepository's findTrees() and findDescendantsTree() (typeorm#7926)

Modified TreeRepository's findTrees() and findDescendantsTree() public methods to now accept an optional object with config options.
For now, said object contains a depth parameter that, if set, will limit how far down the tree those methods will crawl and retrieve nested entities.

BREAKING CHANGE: TreeRepository's protected method buildChildrenEntityTree() now requires a 4th argument. Anyone affected by this break should also review and update their implementation, otherwise this feature will not work.

Closes: typeorm#3909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants