My entity's decimal field is defined as follows:
@Column('decimal', { precision: 10, scale: 2 })
amount!: BigNumber
I am mapping this entity field from my DTO, which manages the request body of my NestJS controller. In the DTO, the field is defined like this:
@Transform(value => new BigNumber(value))
amount!: BigNumber
Removing
@Transform(value => new BigNumber(value))
allows the code to work, but the amount field in the DTO is not a BigNumber object - it just holds a string value. However, in my service component, I need to use functions specific to BigNumber, which becomes impossible since the amount behaves like a string.
For example, when I try to call *.compareTo()
on the DTO field, I receive an error stating that the function compareTo
does not exist. On the other hand, if I add the @Transform decorator to the DTO, functions like compareTo
work fine, but then I encounter errors with the database (I am using PostgreSQL). Thank you for any advice.