mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
|
import { Card } from './card.entity';
|
|
import { Transaction } from './transaction.entity';
|
|
|
|
@Entity('accounts')
|
|
export class Account {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: false, unique: true, name: 'account_reference' })
|
|
@Index({ unique: true })
|
|
accountReference!: string;
|
|
|
|
@Index({ unique: true })
|
|
@Column('varchar', { length: 255, nullable: false, name: 'account_number' })
|
|
accountNumber!: string;
|
|
|
|
@Index({ unique: true })
|
|
@Column('varchar', { length: 255, nullable: false, name: 'iban' })
|
|
iban!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: false, name: 'currency' })
|
|
currency!: string;
|
|
|
|
@Column('decimal', { precision: 10, scale: 2, default: 0.0, name: 'balance' })
|
|
balance!: number;
|
|
|
|
@OneToMany(() => Card, (card) => card.account, { cascade: true })
|
|
cards!: Card[];
|
|
|
|
@OneToMany(() => Transaction, (transaction) => transaction.account, { cascade: true })
|
|
transactions!: Transaction[];
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone' })
|
|
updatedAt!: Date;
|
|
}
|