import {Field, FieldType, HTTPMethod, Model} from '@extollo/lib'

export class PageView extends Model<PageView> {
    protected static table = 'page_views'
    protected static key = 'page_view_id'

    @Field(FieldType.serial, 'page_view_id')
    public pageViewId?: number

    @Field(FieldType.timestamp, 'visited_at')
    public visitedAt = new Date()

    @Field(FieldType.varchar)
    public hostname?: string

    @Field(FieldType.varchar)
    public ip?: string

    @Field(FieldType.varchar)
    public method: HTTPMethod = 'get'

    @Field(FieldType.varchar)
    public endpoint!: string

    @Field(FieldType.bigint, 'user_id')
    public userId?: number

    @Field(FieldType.bool)
    public xhr = false
}
