Created
June 8, 2020 15:56
-
-
Save seandearnaley/2d9aa55878f024f4605951de886eaafb to your computer and use it in GitHub Desktop.
BrainStrike Category Entity / Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| Entity, | |
| Tree, | |
| Column, | |
| PrimaryGeneratedColumn, | |
| TreeChildren, | |
| TreeParent, | |
| ManyToMany, | |
| JoinTable, | |
| } from "typeorm"; | |
| import { Card } from "./Card"; | |
| @Entity() | |
| @Tree("closure-table") | |
| export class Category { | |
| @PrimaryGeneratedColumn("uuid") | |
| id: string; | |
| @Column() | |
| name: string; | |
| @TreeChildren() | |
| children?: Category[]; | |
| @TreeParent() | |
| parent: Category; | |
| @Column({ | |
| type: "timestamp", | |
| nullable: false, | |
| default: () => "LOCALTIMESTAMP", | |
| }) | |
| created: Date; | |
| @Column({ | |
| type: "timestamp", | |
| nullable: false, | |
| default: () => "LOCALTIMESTAMP", | |
| }) | |
| updated: Date; | |
| @ManyToMany(() => Card, (card) => card.categories) | |
| @JoinTable() | |
| cards: Card[]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment