---
# System prepended metadata

title: MdmDropDownList

---


```
{
    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://hackmd.io/_uploads/SyxwIuynh.png)
![](https://hackmd.io/_uploads/SyY-Du13h.png)

[參考連結～～～～～～～～～](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