import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import type Visit from "./Visit.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import ReportSite from "./ReportSite.js"; import DateTime from "@entity-access/entity-access/dist/types/DateTime.js"; import Sql from "@entity-access/entity-access/dist/sql/Sql.js"; @Table("Visitors") export default class Visitor { @Column({ dataType: "BigInt", key: true, generated: "identity"}) visitorID: number; @Column({ dataType: "BigInt"}) @RelateTo(ReportSite, { property: (x) => x.site, inverseProperty: (x) => x.visitors }) siteID: number; @Column({ dataType: "Char", length: 50, nullable: true}) ipAddress: string; @Column({ dataType: "Char", length: 50, nullable: true}) country: string; @Column({ dataType: "Char", nullable: true}) userAgent: string; @Column({ dataType: "Char", length: 400, nullable: true}) device: string; @Column({ dataType: "Char", length: 400, nullable: true}) deviceModel: string; @Column({ dataType: "Char", length: 400, nullable: true}) deviceVendor: string; @Column({ dataType: "Char", length: 400, nullable: true}) referrer: string; @Column({ dataType: "Char", length: 400, nullable: true}) cpu: string; @Column({ dataType: "Char", length: 400, nullable: true}) app: string; @Column({ dataType: "Char", length: 400, nullable: true}) appVersion: string; @Column({ dataType: "Char", length: 400, nullable: true}) engine: string; @Column({ dataType: "Char", length: 400, nullable: true}) engineVersion: string; @Column({ dataType: "Char", length: 400, nullable: true}) os: string; @Column({ dataType: "Char", length: 400, nullable: true}) osVersion: string; @Column({ dataType: "DateTime", default: () => Sql.date.now()}) dateCreated: DateTime; @Column({ dataType: "DateTime", default: () => Sql.date.now()}) dateUpdated: DateTime; @Column({ dataType: "Int", default: () => 1}) totalVisits: number; @Column({ dataType: "Float", default: () => 1}) averageDuration: number; @Column({ dataType: "BigInt", nullable: true}) firstVisitID: number; @Column({ dataType: "BigInt", nullable: true}) lastVisitID: number; site: ReportSite; visits: Visit[]; }