import { User } from "./User" ; import { BaseClass } from "./BaseClass" ; import { Column , Entity , JoinColumn , ManyToOne , RelationId } from "typeorm" ; import { Status } from "../interfaces/Status" ; import { Activity } from "../interfaces/Activity" ; @ Entity ( "sessions" ) export class Session extends BaseClass { @ Column ( { nullable : true } ) @ RelationId ( ( session ) => session . user ) user_id : string ; @ JoinColumn ( { name : "user_id" } ) @ ManyToOne ( ( ) => User , { onDelete : "CASCADE" , } ) user : User ; @ Column ( { nullable : false , select : false } ) session_id : string ; @ Column ( { type : "simple-json" , nullable : true } ) activities : Activity [ ] ; @ Column ( { type : "simple-json" , select : false } ) client_info : { client : string ; os : string ; version : number ; } ; @ Column ( { nullable : false , type : "varchar" } ) status : Status ; } export const PrivateSessionProjection = [ "user_id" , "session_id" , "activities" , "client_info" , "status" , ] ;