UNPKG

@wearesage/schema

Version:

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

45 lines (37 loc) 873 B
import "reflect-metadata"; import { Entity, Id, Property, OneToMany, ManyToOne, ManyToMany } from "../.."; import { Organization } from "./Organization"; import { Task } from "./Task"; @Entity() export class User { @Id() id: string; @Property({ required: true }) name: string; @Property({ required: true, unique: true }) email: string; @ManyToMany({ target: () => Organization, inverse: "members", name: "MEMBER_OF", }) organizations: Organization[] = []; @ManyToOne({ target: () => Organization, inverse: "owners", name: "OWNS_ORGANIZATION", }) ownedOrganization: Organization; @OneToMany({ target: () => Task, inverse: "assignee", name: "ASSIGNED_TO", }) tasks: Task[] = []; @OneToMany({ target: () => Task, inverse: "creator", name: "CREATED_BY", }) createdTasks: Task[] = []; }