import { Entity, Property, ManyToOne, Index, Enum, PrimaryKey } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; import { User } from './user.entity'; import { CreditTransactionType } from '../interface/user'; @Entity({ tableName: 'credit_transactions' }) @Index({ properties: ['user'] }) export class CreditTransaction extends BaseEntity { @PrimaryKey({ type: 'bigint', autoincrement: true }) id: bigint @ManyToOne(() => User) user!: User; @Property() orderId: string @Property({ type: 'decimal', precision: 10, scale: 0 }) amount!: number; @Property({ type: 'decimal', precision: 10, scale: 0 }) balance!: number; @Enum(() => CreditTransaction) type!: CreditTransactionType; }