const mongoose = require('mongoose') const ObjectID = mongoose.Schema.Types.ObjectId const transactionSchema = new mongoose.Schema( { type: { type: String, enum: ['withdraw', 'deposit'], required: true, }, status: { type: String, enum: ['failed', 'pending', 'finished'], required: true, }, source: { type: String, enum: ['normal'], }, value: { type: Number, required: true, }, date: { type: Date, default: Date.now(), }, description: String, userId: { type: ObjectID, ref: 'User', }, belongingId: { type: ObjectID, ref: 'Belonging', }, }, { toJSON: { virtuals: true }, toObject: { virtuals: true }, timestamps: true, } ) const Transaction = mongoose.model('Transaction', transactionSchema) module.exports = Transaction