SudoSOS Back-end API / internal/transformers / DineroTransformer
Class: DineroTransformer ​
A singleton class for converting monetary Dinero values from and to integer database representation.
Implements ​
ValueTransformer
Accessors ​
Instance ​
Get Signature ​
ts
get static Instance(): DineroTransformer;Get Singleton instance of the transformer.
Returns ​
DineroTransformer
Methods ​
from() ​
ts
from(value): Dinero;Converts a monetary value to its Dinero object representation.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
value | string | number | The monetary value represented as an integer. |
Returns ​
Dinero
Throws ​
If value is non-integer.
Implementation of ​
ts
ValueTransformer.fromto() ​
ts
to(value): number;Converts a monetary value to it's database integer representation.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
value | Dinero | the monetary value represented in a Dinero object. |
Returns ​
number
Throws ​
if precision is not the default precision.
Throws ​
if currency is not the default currency.
Implementation of ​
ts
ValueTransformer.to