@wearesage/schema
Version:
A flexible schema definition and validation system for TypeScript with multi-database support
32 lines (27 loc) • 602 B
text/typescript
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.
*/
()
export class CartItem {
()
id: string;
({ required: true, default: 1 })
quantity: number;
({
target: () => Cart,
inverse: "items",
name: "IN_CART",
})
cart: Cart;
({
target: () => Product,
inverse: "cartItems",
name: "CART_REFERENCES_PRODUCT",
})
product: Product;
}