WITHOUT ROWID

This commit is contained in:
Ben Wilson
2023-08-11 09:19:26 -04:00
parent 36d596bd04
commit c897a6413e
3 changed files with 38 additions and 23 deletions
+15 -10
View File
@@ -1,27 +1,32 @@
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';
import { DateTimeTransformer } from '../utils/DateTimeTransformer';
import { TrackedEntity } from '../utils/TrackedEntity.entity';
@Entity()
//https://www.sqlite.org/withoutrowid.html
//The WITHOUT ROWID optimization is likely to be helpful for tables that have non-integer
// or composite (multi-column) PRIMARY KEYs and that do not store large strings or BLOBs.
//WITHOUT ROWID tables work best when individual rows are not too large.
@Entity({ withoutRowid: true })
@Index(['address', 'clientName', 'sessionId'], { unique: true })
export class ClientEntity extends TrackedEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ length: 62, type: 'varchar' })
@PrimaryColumn({ length: 62, type: 'varchar' })
address: string;
@Column({ length: 64, type: 'varchar' })
@PrimaryColumn({ length: 64, type: 'varchar' })
clientName: string;
@PrimaryColumn({ length: 8, type: 'varchar' })
sessionId: string;
@Column({ length: 128, type: 'varchar', nullable: true })
userAgent: string;
@Index()
@Column({ length: 8, type: 'varchar', unique: true })
sessionId: string;
@Column({ type: 'datetime', transformer: new DateTimeTransformer() })
startTime: Date;