UNPKG

@wearesage/schema

Version:

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

35 lines (29 loc) 658 B
import "reflect-metadata"; import { Entity, Id, Property, ManyToOne } from "../.."; import { Order } from "./Order"; import { Product } from "./Product"; /** * Each OrderItem references exactly one Order (ManyToOne) * and one Product (ManyToOne). */ @Entity() export class OrderItem { @Id() id: string; @Property({ required: true, default: 1 }) quantity: number; @Property() unitPrice: number; @ManyToOne({ target: () => Order, inverse: "items", name: "IN_ORDER", }) order: Order; @ManyToOne({ target: () => Product, inverse: "orderItems", name: "ORDER_ITEM_REFERENCES_PRODUCT", }) product: Product; }