@wearesage/schema
Version:
A flexible schema definition and validation system for TypeScript with multi-database support
30 lines (24 loc) • 583 B
text/typescript
import "reflect-metadata";
import { Entity, Id, Property, ManyToMany } from "../..";
import { Product } from "./Product";
/**
* A Category can have many products,
* and a product can belong to many categories (Many-to-Many).
*/
()
export class Category {
()
id: string;
({ required: true, unique: true })
name: string;
()
description: string;
({ default: () => new Date() })
createdAt: Date;
({
target: () => Product,
inverse: "categories",
name: "HAS_PRODUCT",
})
products: Product[] = [];
}