import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import Index from "@entity-access/entity-access/dist/decorators/Index.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import { StoreItem } from "./StoreItem.js"; import WebSite from "./WebSite.js"; /** * This table is separate to hide the insights from customers. * Only public insights might appear. */ @Table("StoreInsights") @Index({ name: "IX_StoreInsights_Store_Name", columns: [ { name: (x) => x.storeID, descending: true }, { name: (x) => x.name, descending: false } ], filter: (x) => x.storeID !== null }) @Index({ name: "IX_StoreInsights_StoreItem_Name", columns: [ { name: (x) => x.storeItemID, descending: true }, { name: (x) => x.name, descending: false } ], filter: (x) => x.storeItemID !== null }) export class StoreInsight { @Column({ dataType: "BigInt", key: true, generated: "identity" }) insightID: number; @Column({ dataType: "BigInt", nullable: true }) @RelateTo(WebSite, { property: (x) => x.store, inverseProperty: (x) => x.insights }) storeID: number; @Column({ dataType: "BigInt", nullable: true }) @RelateTo(StoreItem, { property: (x) => x.storeItem, inverseProperty: (x) => x.insights }) storeItemID: number; @Column({ dataType: "Char", length: 200 }) name: string; @Column({ dataType: "Decimal" }) value: number; @Column({ dataType: "Boolean" }) isPublic: boolean; store: WebSite; storeItem: StoreItem; }