const sequelize = require("../config/dbconnection");
const Sequelize = require("sequelize");
const Admin = require("../models/admin");
const { empty, getAgoString } = require("../Helpers/Common");

const UserActionLog=sequelize.define('user_action_log',{
    ID:{ type: Sequelize.INTEGER, allowNull: false, primaryKey: true, autoIncrement: true },
    userid:{type:Sequelize.INTEGER,allowNull:false,defaultValue:null},
    message:{type:Sequelize.INTEGER,allowNull:true,defaultValue:null},
    IP:{type:Sequelize.CHAR,allowNull:true,defaultValue:null},
    timestamp:{type:Sequelize.INTEGER,allowNull:false,defaultValue:null},
    url:{type:Sequelize.CHAR,allowNull:true,defaultValue:null},
    taskid:{type:Sequelize.INTEGER,allowNull:true,defaultValue:null},
    taskid:{type:Sequelize.INTEGER,allowNull:true,defaultValue:null},
    project_id:{type:Sequelize.INTEGER,allowNull:true,defaultValue:null},
    project_task_id:{type:Sequelize.INTEGER,allowNull:true,defaultValue:null},

},{tableName:'user_action_log',timestamps:false})


const addUserLog=async(data)=>{
    try {
        console.log(data,'******************')
         let result = await UserActionLog.create(data)
         if(!empty(result)){
            return true
         }else{
            return false
         }

    } catch (error) {
        console.log(error);
    }
}
module.exports={
    addUserLog,
}