import {
  Column,
  Entity,
  ManyToOne,
  PrimaryColumn,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from "typeorm";
import { calendarType } from "./calendarType";

@Entity()
export class calendar {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @Column({ type: "datetime", nullable: false })
  starttime: Date;

  @Column({ type: "datetime", nullable: false })
  endtime: Date;

  @Column({ type: "varchar", length: 255, nullable: false })
  title: string;

  @Column({ type: "text", nullable: true })
  content: string;

  @Column({ type: "text", nullable: true })
  location: string;

  @Column({ type: "boolean", default: false })
  allDay: boolean;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @ManyToOne(() => calendarType, (t) => t.calendar, {
    nullable: false,
    onDelete: "RESTRICT",
    onUpdate: "RESTRICT",
  })
  type: calendarType;
}