@wearesage/schema
Version:
A flexible schema definition and validation system for TypeScript with multi-database support
38 lines (31 loc) • 690 B
text/typescript
import "reflect-metadata";
import { Entity, Id, Property, ManyToOne } from "../..";
import { User } from "./User";
import { Product } from "./Product";
/**
* A Review belongs to exactly one User (the author),
* and exactly one Product.
*/
()
export class Review {
()
id: string;
({ required: true })
content: string;
()
rating: number; // e.g. 1-5
({ default: () => new Date() })
createdAt: Date;
({
target: () => User,
inverse: "reviews",
name: "AUTHORED_BY",
})
author: User;
({
target: () => Product,
inverse: "reviews",
name: "REVIEWS_PRODUCT",
})
product: Product;
}