[Question] How to return the `mpath` field with TreeRepository?

See original GitHub issue

Issue type:

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

Database system/driver:

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

here is my entity

import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  Tree,
  TreeChildren,
  TreeParent,
} from 'typeorm';

@Entity()
@Tree('materialized-path')
export class Permission {
  permission: Promise<Permission>;
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({
    length: 20,
  })
  name: string;

  @Column({
    length: 100,
  })
  identify: string;

  @Column({
    length: 20,
    nullable: true,
  })
  alias: string;

  @Column({
    type: 'int',
    default: 0,
  })
  type: number;

  @Column({
    type: 'int',
    default: 1,
  })
  isShow: number;

  @Column({
    type: 'int',
    default: false,
  })
  hasChildren: boolean;

  @Column({
    length: 100,
    nullable: true,
  })
  icon: string;

  @Column({
    type: 'int',
    default: 0,
  })
  sortId: number;

  @Column({
    length: 100,
    nullable: true,
  })
  url: string;

  @TreeChildren()
  children: Permission[];

  @TreeParent()
  parent: Permission;

  @CreateDateColumn()
  createdAt;

  @UpdateDateColumn()
  updatedAt;
}

I used the @Tree('materialized-path'), it generated the mpath parentId field in my tables

this.permissionRepository.find({
        where: { parent: pid },
      });

How can I return the mpath field ?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

3reactions
avelecommented, May 5, 2021

My workaround is to specify mpath field as mpath?: string, without column decorator. And then for entity instance set TypeORM mpath field not virtual: entityName.metadata.columns.find(x => x.databaseName === 'mpath').isVirtual = false

2reactions
enkocommented, Oct 15, 2019

@arminghm I am using this:

    @Column({
        type: 'text',
        name: 'mpath',
        update: false,
        insert: false,
    })
    public path?: string;
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change "mpath" field name of materialized-path tree in ...
Is there any way to change the name of the "mpath" column that is automatically generated when using the materialized-path tree structure on ......
Read more >
Class TreeRepository<Entity> - typeorm
Returns object that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema...
Read more >
[PATCH v4 00/25] InfiniBand Transport (IBTRS) and Network Block ...
IBTRS is multipath capable and provides I/O fail-over and load-balancing functionality, ... + + if (q) + ibnbd_clt_dev_requeue(q); + + return !!q; ...
Read more >
disjoint decision trees: Topics by Science.gov
The Decision Tree involves a sequence of questions/decisions that can be answered in ... Decision trees are widely used in the field of...
Read more >
3-540-45812-3.pdf - Springer Link
underlying QoS routing algorithm (i.e., Q-OSPF with the enhanced routing algo- ... during exchange; (3) helps SP in using the information generated by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found