Skip to content

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 ​

ParameterTypeDescription
valuestring | numberThe monetary value represented as an integer.

Returns ​

Dinero

Throws ​

If value is non-integer.

Implementation of ​

ts
ValueTransformer.from

to() ​

ts
to(value): number;

Converts a monetary value to it's database integer representation.

Parameters ​

ParameterTypeDescription
valueDinerothe 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