``` { id: uuid i18key: string type: enum parent_id: uuid path: string-array active: boolean default: boolean } ``` | id | name | type | parent_id | path | | --- | ------- | -------- | --------- |:-----------:| | 123 | media | | | | | 112 | service | | | | | 456 | TV | channel | 123 | | | 789 | 中天 | platform | 456 | ["123/456"] | | 012 | 東森 | platform | 456 | |   [參考連結~~~~~~~~~](https://www.slideshare.net/billkarwin/models-for-hierarchical-data) - 後來沒採用下面的方式 ```javascript import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'; @Entity() export class MdmDropDownList { @PrimaryGeneratedColumn('uuid') id: string; @Column() i18key: string; @Column() type: string; @ManyToOne(() => YourEntity, { onDelete: 'CASCADE' }) // This creates the Foreign Key constraint @JoinColumn() parent: YourEntity; @Column('uuid', { nullable: true }) group: string; @Column() default: boolean; } ``` 參考 - https://schinckel.net/2014/09/13/long-live-adjacency-lists/ - https://typeorm.io/tree-entities#tree-entities
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up