import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import { User } from "./User.js"; import AppFile from "./AppFile.js"; import Mailbox from "./Mailbox.js"; import Index from "@entity-access/entity-access/dist/decorators/Index.js"; @Table("UserPins") @Index({ name: "IX_UserPins_UseID", columns: [ { name: (x) => x.userID, descending: false }, { name: (x) => x.appFileID, descending: false}, { name: (x) => x.mailboxID, descending: false}, ], unique: true }) export default class UserPin { @Column({ dataType: "BigInt", key: true, generated: "identity"}) public pinID: number; @Column({ dataType: "BigInt"}) @RelateTo(User, { property: (up) => up.user, inverseProperty: (u) => u.pins, foreignKeyConstraint: { onDelete: "cascade" } }) public userID: number; public user: User; @Column({ dataType: "BigInt", nullable: true}) @RelateTo(AppFile, { property: (up) => up.file, inverseProperty: (f) => f.userPins, foreignKeyConstraint: { onDelete: "cascade" } }) public appFileID: number; @Column({ dataType: "BigInt", nullable: true }) @RelateTo(Mailbox, { property: (up) => up.mailbox, inverseProperty: (mb) => mb.userPins, foreignKeyConstraint: { onDelete: "cascade" } }) public mailboxID: number; public file: AppFile; public mailbox: Mailbox; }