UNPKG

@wearesage/schema

Version:

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

60 lines (49 loc) 1.06 kB
import "reflect-metadata"; import { Entity, Id, Property, OneToMany, ManyToOne, ManyToMany } from "../.."; import { User } from "./User"; import { Reaction } from "./Reaction"; import { Hashtag } from "./Hashtag"; import { Group } from "./Group"; @Entity() export class Post { @Id() id: string; @Property({ required: true }) content: string; @Property() imageUrl: string; @Property() createdAt: Date; @Property() isPublic: boolean = true; @ManyToOne({ target: () => User, inverse: "posts", name: "CREATED_BY", }) author: User; @OneToMany({ target: () => Comment, inverse: "post", name: "HAS_COMMENT", }) comments: Comment[] = []; @OneToMany({ target: () => Reaction, inverse: "post", name: "HAS_REACTION", }) reactions: Reaction[] = []; @ManyToMany({ target: () => Hashtag, inverse: "posts", name: "HAS_HASHTAG", }) hashtags: Hashtag[] = []; @ManyToOne({ target: () => Group, inverse: "posts", name: "BELONGS_TO_GROUP", }) group: Group; }