35 lines
630 B
TypeScript
35 lines
630 B
TypeScript
import { IsNotEmpty } from "class-validator";
|
|
import {
|
|
Column,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn
|
|
} from "typeorm";
|
|
import { Project } from "./project.entity";
|
|
|
|
@Entity()
|
|
export class Task {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column()
|
|
@IsNotEmpty()
|
|
description: string;
|
|
|
|
@Column({ type: "timestamptz" })
|
|
@IsNotEmpty()
|
|
createdAt: Date;
|
|
|
|
@Column({ type: "timestamptz", nullable: true })
|
|
finishedAt?: Date;
|
|
|
|
@ManyToOne((_type) => Project, (project) => project.tasks,{
|
|
onUpdate: "CASCADE",
|
|
onDelete: "CASCADE",
|
|
})
|
|
@JoinColumn()
|
|
@IsNotEmpty()
|
|
project: Project;
|
|
}
|