const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');
const Member = require('./member');
const Product = require('./product');

const Borrowtransaction = sequelize.define('Borrowtransaction', {
  
    borrow_id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
    },
    member_id: {
        type: DataTypes.UUID,
        references: {
            model: Member,
            key: 'member_id',
        },
        allowNull: false,
    },
    product_id: {
        type: DataTypes.UUID,
        references: {
            model: Product,
            key: 'product_id',
        },
        allowNull: false,
    },
    borrow_amount: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    borrow_date: {
        type: DataTypes.DATE,
        allowNull: false,
    },
    borrow_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    borrow_return: {
        type: DataTypes.DATE,
        allowNull: true,
    },
    borrow_status: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    borrow_remark: {
        type: DataTypes.TEXT,
        allowNull: true,
    }
}, {
    tableName: 'borrow_transaction',
    timestamps: false,
    underscored: true,
});

module.exports = Borrowtransaction;