TypeORM findDescendants yielding unexpected results (it returns itself) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!FindOption vs QueryBuilder in typeormTypeORM upsert - create if not existSyntaxError: Unexpected token import typeORM entityTypeORM selected subquery result not showing after queryingTypeORM how to seed databaseTypeORM Logs To The Console But Doesn't ReturnTypeORM Polymorphic Relationstypeorm “OR” operatorTypeOrm - findOne returns unexpected valuetypeorm: Select options for relationship

How to install press fit bottom bracket into new frame

What was the first language to use conditional keywords?

Is there a kind of relay only consumes power when switching?

How can I reduce the gap between left and right of cdot with a macro?

How does light 'choose' between wave and particle behaviour?

The code below, is it ill-formed NDR or is it well formed?

How would a mousetrap for use in space work?

How to write the following sign?

What is the difference between globalisation and imperialism?

Can a new player join a group only when a new campaign starts?

Morning, Afternoon, Night Kanji

Maximum summed subsequences with non-adjacent items

Did Krishna say in Bhagavad Gita "I am in every living being"

Sum letters are not two different

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

Selecting user stories during sprint planning

Why should I vote and accept answers?

Performance gap between vector<bool> and array

How to react to hostile behavior from a senior developer?

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Why do we bend a book to keep it straight?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Time to Settle Down!

Using audio cues to encourage good posture



TypeORM findDescendants yielding unexpected results (it returns itself)



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!FindOption vs QueryBuilder in typeormTypeORM upsert - create if not existSyntaxError: Unexpected token import typeORM entityTypeORM selected subquery result not showing after queryingTypeORM how to seed databaseTypeORM Logs To The Console But Doesn't ReturnTypeORM Polymorphic Relationstypeorm “OR” operatorTypeOrm - findOne returns unexpected valuetypeorm: Select options for relationship



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Consider the following:



@Entity()
@Tree('closure-table')
export class Group

@PrimaryGeneratedColumn('uuid')
id: string;

@Column()
name: string;

@TreeChildren()
children: Group[];

@TreeParent()
parent: Group;




and then lets create some groups ...



const groupRepo = conn.getRepository(Group)
const parentGroup = new Group()
parentGroup.name = "dogs"
await groupRepo.save(parentGroup)

const childGroup = new Group()
childGroup.name = "puppies";
childGroup.parent = parentGroup;
await groupRepo.save(childGroup)


okay, and now try to load the tree:



 const groupTreeRepo = conn.getTreeRepository(Group);

const parent = await groupRepo.findOne(group.id);

const trees = await groupTreeRepo.findTrees();

// yields the expected result
// a single tree `dogs` with `puppies` as child
console.log('Trees', trees);

const children = await groupTreeRepo.findDescendants(parent);

// yields unexpected results: yields both groups.
// i only expect this to return the puppy group
console.log('Children: ', children);


Do I have something either (a) misconfigured or (b) am I calling findDesendants the wrong way










share|improve this question






























    0















    Consider the following:



    @Entity()
    @Tree('closure-table')
    export class Group

    @PrimaryGeneratedColumn('uuid')
    id: string;

    @Column()
    name: string;

    @TreeChildren()
    children: Group[];

    @TreeParent()
    parent: Group;




    and then lets create some groups ...



    const groupRepo = conn.getRepository(Group)
    const parentGroup = new Group()
    parentGroup.name = "dogs"
    await groupRepo.save(parentGroup)

    const childGroup = new Group()
    childGroup.name = "puppies";
    childGroup.parent = parentGroup;
    await groupRepo.save(childGroup)


    okay, and now try to load the tree:



     const groupTreeRepo = conn.getTreeRepository(Group);

    const parent = await groupRepo.findOne(group.id);

    const trees = await groupTreeRepo.findTrees();

    // yields the expected result
    // a single tree `dogs` with `puppies` as child
    console.log('Trees', trees);

    const children = await groupTreeRepo.findDescendants(parent);

    // yields unexpected results: yields both groups.
    // i only expect this to return the puppy group
    console.log('Children: ', children);


    Do I have something either (a) misconfigured or (b) am I calling findDesendants the wrong way










    share|improve this question


























      0












      0








      0


      1






      Consider the following:



      @Entity()
      @Tree('closure-table')
      export class Group

      @PrimaryGeneratedColumn('uuid')
      id: string;

      @Column()
      name: string;

      @TreeChildren()
      children: Group[];

      @TreeParent()
      parent: Group;




      and then lets create some groups ...



      const groupRepo = conn.getRepository(Group)
      const parentGroup = new Group()
      parentGroup.name = "dogs"
      await groupRepo.save(parentGroup)

      const childGroup = new Group()
      childGroup.name = "puppies";
      childGroup.parent = parentGroup;
      await groupRepo.save(childGroup)


      okay, and now try to load the tree:



       const groupTreeRepo = conn.getTreeRepository(Group);

      const parent = await groupRepo.findOne(group.id);

      const trees = await groupTreeRepo.findTrees();

      // yields the expected result
      // a single tree `dogs` with `puppies` as child
      console.log('Trees', trees);

      const children = await groupTreeRepo.findDescendants(parent);

      // yields unexpected results: yields both groups.
      // i only expect this to return the puppy group
      console.log('Children: ', children);


      Do I have something either (a) misconfigured or (b) am I calling findDesendants the wrong way










      share|improve this question
















      Consider the following:



      @Entity()
      @Tree('closure-table')
      export class Group

      @PrimaryGeneratedColumn('uuid')
      id: string;

      @Column()
      name: string;

      @TreeChildren()
      children: Group[];

      @TreeParent()
      parent: Group;




      and then lets create some groups ...



      const groupRepo = conn.getRepository(Group)
      const parentGroup = new Group()
      parentGroup.name = "dogs"
      await groupRepo.save(parentGroup)

      const childGroup = new Group()
      childGroup.name = "puppies";
      childGroup.parent = parentGroup;
      await groupRepo.save(childGroup)


      okay, and now try to load the tree:



       const groupTreeRepo = conn.getTreeRepository(Group);

      const parent = await groupRepo.findOne(group.id);

      const trees = await groupTreeRepo.findTrees();

      // yields the expected result
      // a single tree `dogs` with `puppies` as child
      console.log('Trees', trees);

      const children = await groupTreeRepo.findDescendants(parent);

      // yields unexpected results: yields both groups.
      // i only expect this to return the puppy group
      console.log('Children: ', children);


      Do I have something either (a) misconfigured or (b) am I calling findDesendants the wrong way







      typescript typeorm






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 23:34









      galkin

      2,62421637




      2,62421637










      asked Mar 8 at 20:28









      JonathanJonathan

      10.3k84982




      10.3k84982






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070546%2ftypeorm-finddescendants-yielding-unexpected-results-it-returns-itself%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070546%2ftypeorm-finddescendants-yielding-unexpected-results-it-returns-itself%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко