You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.2 KiB

import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, ManyToOne, OneToMany, OneToOne, JoinColumn, CreateDateColumn, Not, IsNull } from "typeorm";
import { MovieInfo } from "./MovieInfo";
import { MovieTorrent } from "./MovieTorrent";
import { User } from "./User";
@Entity()
export class MovieTicket extends BaseEntity
{
@PrimaryGeneratedColumn()
id!: number;
@Column({ type: "int", nullable: true })
tmdbId!: number | null;
@Column({ type: "varchar", length: 27, nullable: true })
imdbId!: string | null;
@Column({ type: "varchar" })
title!: string;
@Column({ type: "year", nullable: true })
year!: number | null;
@CreateDateColumn()
createdAt!: Date;
@Column({ default: false })
isFulfilled!: boolean;
@Column({ default: false })
isCanceled!: boolean;
@Column({ default: false })
isStale!: boolean;
@ManyToOne(() => User, user => user.movieTickets)
user!: User;
@OneToMany(() => MovieTorrent, torrent => torrent.movieTicket)
torrents!: MovieTorrent[];
@OneToOne(() => MovieInfo, { nullable: true })
@JoinColumn()
info!: MovieInfo | null;
/**
* Fulfill the current ticket instance
*/
async fulfill() {
this.isFulfilled = true;
return await this.save();
}
}