Files
mbmanager-api/components/transaction/transactionModel.js
T
kavehhn ca911b97a0 REFACTOR: Belonging → Property system migration + utilities update
Property system:
- Rename belonging → property throughout (model, controller, routes, service)
- Add property sub-models: buildingModel, landModel, belongingModel
- Add property lifecycle events: createProperty, deleteProperty
- Add propertyStatus component (model, controller, routes, service, seeder)
- Add commodity and commodityTransaction model stubs

Infrastructure:
- Update transactionModel and transactionService
- Update events/index.js for new property events
- Update seeder (seederDBConnection, seederRunner)
- Update typesense client configuration
- Update upload utilities (bucket, minio)
- Update featureModel and featureSeeder
- Update categorySeeder
- Update TsApiFeatures utility
- Remove docker-compose.yml (moved to root)
- Remove legacy belonging component files
2026-08-11 20:35:47 +03:30

57 lines
1.4 KiB
JavaScript

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',
},
userName: {
type: String,
required: true,
},
propertyId: {
type: ObjectID,
ref: 'Property',
},
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true },
timestamps: true,
}
)
transactionSchema.index({ type: 1 })
transactionSchema.index({ status: 1 })
transactionSchema.index({ value: 1 })
transactionSchema.index({ propertyId: 1, status: 1 })
transactionSchema.index({ propertyId: 1, type: 1, status: 1 })
const Transaction = mongoose.model('Transaction', transactionSchema)
module.exports = Transaction