Skip to content

Instantly share code, notes, and snippets.

@michaelpanik
Created October 20, 2021 15:28
Show Gist options
  • Save michaelpanik/91e7774fb1011b8ee57445e49b6112ca to your computer and use it in GitHub Desktop.
Save michaelpanik/91e7774fb1011b8ee57445e49b6112ca to your computer and use it in GitHub Desktop.
Entities
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinTable,
ManyToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from "typeorm";
import { Employee } from "./Employee.entity";
import { Ghost } from "./Ghost.entity";
@Entity()
export class Capture extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@ManyToMany(() => Ghost)
@JoinTable()
ghosts: Ghost[];
@ManyToMany(() => Employee)
@JoinTable()
employees: Employee[];
@Column({ type: "timestamptz" })
last_sighting: Date;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from "typeorm";
import { Capture } from "./Capture.entity";
@Entity()
export class Ghost extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column({ type: "timestamptz" })
last_sighting: Date;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment