// models/session.js
'use strict';
const { Model } = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Session extends Model {
    static associate(models) {
      Session.belongsTo(models.User, { foreignKey: 'userId', as: 'user' });
      Session.belongsTo(models.Register, { foreignKey: 'registerId', as: 'register' });
    }
  }
  Session.init({
    userId: DataTypes.INTEGER,
    token: DataTypes.STRING,
    ipAddress: DataTypes.STRING,
    userAgent: DataTypes.STRING,
    expiresAt: DataTypes.DATE,
    registerId: DataTypes.INTEGER
  }, {
    sequelize,
    modelName: 'Session',
    tableName: 'sessions',
    timestamps: true
  });
  return Session;
};
