const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const transactionSchema = new Schema(
    {
        userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
        transCode: { type: String, required: true },
        type: { type: String, enum: ['DEPOSIT', 'PURCHASE', 'REFUND', 'SPIN', 'REWARD'], required: true },
        amount: { type: Number, required: true },
        balanceBefore: { type: Number, required: true },
        balanceAfter: { type: Number, required: true },
        content: { type: String },
    },
    {
        timestamps: true,
    },
);

module.exports = mongoose.model('transaction', transactionSchema);
