UNPKG

@wearesage/schema

Version:

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

34 lines (27 loc) 560 B
import "reflect-metadata"; import { Entity, Id, Property, ManyToOne, ManyToMany } from "../.."; import { User } from "./User"; import { Tag } from "./Tag"; @Entity() export class Post { @Id() id: string; @Property({ required: true }) title: string; @Property({ required: true }) content: string; @Property() createdAt: Date; @ManyToOne({ target: () => User, inverse: "posts", name: "AUTHORED", }) author: User; @ManyToMany({ target: () => Tag, inverse: "posts", name: "HAS_TAG", }) tags: Tag[] = []; }