UNPKG

@wearesage/schema

Version:

A flexible schema definition and validation system for TypeScript with multi-database support

53 lines (41 loc) 857 B
import "reflect-metadata"; import { Entity, Id, Property, ManyToOne, ManyToMany } from "../.."; import { User } from "./User"; import { Group } from "./Group"; @Entity() export class Event { @Id() id: string; @Property({ required: true }) title: string; @Property() description: string; @Property() location: string; @Property({ required: true }) startTime: Date; @Property() endTime: Date; @Property() imageUrl: string; @Property() isPublic: boolean = true; @ManyToOne({ target: () => User, inverse: "hostedEvents", name: "HOSTED_BY", }) host: User; @ManyToMany({ target: () => User, inverse: "eventsAttending", name: "HAS_ATTENDEE", }) attendees: User[] = []; @ManyToOne({ target: () => Group, inverse: "events", name: "BELONGS_TO_GROUP", }) group: Group; }