Skip to content

Instantly share code, notes, and snippets.

@mattbajorek
Last active September 5, 2021 00:02
Show Gist options
  • Save mattbajorek/36652da517b59746afa885543862bbf7 to your computer and use it in GitHub Desktop.
Save mattbajorek/36652da517b59746afa885543862bbf7 to your computer and use it in GitHub Desktop.
Final account entity with balance column
import { Transform } from 'class-transformer';
import { Column, Entity } from 'typeorm';
import { DecimalToString, DecimalTransformer } from './decimal.transformer';
@Entity('account')
export class AccountEntity {
@Column({ name: 'balance', type: 'decimal', precision: 10, scale: 2, default: 0.0, transformer: new DecimalTransformer() })
@Transform(DecimalToString(), { toPlainOnly: true })
public balance: Decimal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment