mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
db refactor
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';
|
||||
import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
import { ClientStatisticsEntity } from '../client-statistics/client-statistics.entity';
|
||||
import { TrackedEntity } from '../utils/TrackedEntity.entity';
|
||||
|
||||
|
||||
@Entity()
|
||||
@Index(['address', 'clientName', 'sessionId'], { unique: true })
|
||||
@Index("IDX_unique_nonce", { synchronize: false })
|
||||
export class ClientEntity extends TrackedEntity {
|
||||
|
||||
|
||||
@PrimaryColumn({ length: 62, type: 'varchar' })
|
||||
address: string;
|
||||
|
||||
@PrimaryColumn({ length: 64, type: 'varchar' })
|
||||
clientName: string;
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Index()
|
||||
@PrimaryColumn({ length: 8, type: 'varchar' })
|
||||
@Column({ length: 62, type: 'varchar' })
|
||||
address: string;
|
||||
|
||||
@Column({ length: 64, type: 'varchar' })
|
||||
clientName: string;
|
||||
|
||||
@Column({ length: 8, type: 'varchar', })
|
||||
sessionId: string;
|
||||
|
||||
|
||||
@@ -23,7 +26,6 @@ export class ClientEntity extends TrackedEntity {
|
||||
userAgent: string;
|
||||
|
||||
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
startTime: Date;
|
||||
|
||||
@@ -33,5 +35,11 @@ export class ClientEntity extends TrackedEntity {
|
||||
@Column({ default: 0, type: 'decimal' })
|
||||
hashRate: number;
|
||||
|
||||
@OneToMany(
|
||||
() => ClientStatisticsEntity,
|
||||
clientStatisticsEntity => clientStatisticsEntity.client
|
||||
)
|
||||
statistics: ClientStatisticsEntity[]
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user