import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document, Types } from "mongoose";
import moment from "moment";
import * as Model from './index'
import { Users } from "./user.schema";
// const types= [null, 'USER', 'ADMIN','SELLER']
const device_types = [null, 'IOS', 'ANDROID', 'WEB']

@Schema()
export class Sessions extends Document {

    @Prop({ type: Types.ObjectId, ref: "users", default: null })
    admin_id: Types.ObjectId = null

    @Prop({ type: Types.ObjectId, ref: "users", default: null })
    vendor_id: Types.ObjectId = null

    @Prop({ type: Types.ObjectId, ref: Model.User.Users.name, default: null })
    user_id: Types.ObjectId = null

    @Prop({ default: null })
    type: string = null;

    @Prop({ default: null })
    access_token: string = null;

    @Prop({ default: 'WEB', enum: device_types })
    device_type: string;

    @Prop({ default: null })
    fcm_token: string = null;

    @Prop({ default: null })
    token_gen_at: number = null;

    @Prop({ default: moment().utc().valueOf() })
    created_at: number = moment().utc().valueOf();
}

export const SessionSchema = SchemaFactory.createForClass(Sessions);  