'use strict';
// var mongoose = require('mongoose');
import { Schema, model, connect } from 'mongoose';
enum Action {
    LOGIN = 'LOGIN',
    SIGNUP = 'SIGNUP',
    LOGOUT = 'LOGOUT'  
}
var  loginHistorySchema = new Schema(
    {
        user_id:{
            type: Schema.Types.ObjectId,
            ref:'User'
        },
        last_login_logout: {
            type: Date,
            default: new Date()
        },   
        action: {
            type: String,
            enum: Action,
            default: Action.LOGIN
        }    
    },
    {
        timestamps: true,
    },
);

let loginHistory = model('login-history', loginHistorySchema)
//module.exports.User =  mongoose.model('User', userSchema);
module.exports = {loginHistory, loginHistorySchema}