UNPKG

@wearesage/schema

Version:

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

32 lines (27 loc) 602 B
import "reflect-metadata"; import { ManyToOne, Entity, Id, Property } from "../.."; import { Cart } from "./Cart"; import { Product } from "./Product"; /** * Each CartItem belongs to exactly one Cart, * and references exactly one Product. */ @Entity() export class CartItem { @Id() id: string; @Property({ required: true, default: 1 }) quantity: number; @ManyToOne({ target: () => Cart, inverse: "items", name: "IN_CART", }) cart: Cart; @ManyToOne({ target: () => Product, inverse: "cartItems", name: "CART_REFERENCES_PRODUCT", }) product: Product; }