40 lines
781 B
TypeScript
40 lines
781 B
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
} from 'typeorm';
|
|
import { Wallet } from './wallet.entity';
|
|
|
|
@Entity({ name: 'wallet_transactions' })
|
|
export class WalletTransaction {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@ManyToOne(() => Wallet, (wallet) => wallet.transactions, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
wallet: Wallet;
|
|
|
|
@Column({ length: 30 })
|
|
type: string;
|
|
|
|
@Column({
|
|
type: 'numeric',
|
|
precision: 12,
|
|
scale: 2,
|
|
transformer: {
|
|
to: (value: number) => value,
|
|
from: (value: string) => Number(value),
|
|
},
|
|
})
|
|
amount: number;
|
|
|
|
@Column({ type: 'varchar', length: 255, nullable: true })
|
|
description?: string | null;
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
}
|