@wearesage/schema
Version:
A flexible schema definition and validation system for TypeScript with multi-database support
44 lines (35 loc) • 729 B
text/typescript
import "reflect-metadata";
import { Entity, Id, Property, OneToMany, ManyToMany } from "../..";
import { Post } from "./Post";
()
export class User {
()
id: string;
({ required: true })
name: string;
({ required: true, unique: true })
email: string;
// Timestamps
()
createdAt: Date;
()
updatedAt: Date;
({
target: () => User,
inverse: "followers",
name: "FOLLOWS",
})
following: User[] = [];
({
target: () => User,
inverse: "following",
name: "FOLLOWS",
})
followers: User[] = [];
({
target: () => Post,
inverse: "author",
name: "AUTHORED",
})
posts: Post[] = [];
}