Specifies constant values used for rounding modes in the number library.

Rounding mode specifies rounding behavior of numerical and/or rounding operations in the number library, specifically indicating how the least significant digit of the result should be calculated. There are several well known rounding modes. NoSQL database supports rounding modes used by Java BigDecimal and specified as RoundingMode enumeration. Also see documentation for the number library of your choice on supported rounding modes.

This object may be specified as RoundingModes property and it helps the driver determine the rounding mode constant values (which are usually Javascript numbers) for different rounding modes used by the number library. The driver uses it to infer which rounding mode is used by the library or set as roundingMode property, see NumberLibRoundingMode.

In most cases, it is not necessary to set RoundingModes and thus use this object. Specifically, this property is not necessary if:

  • You wish to keep default rounding mode ROUND_HALF_UP
  • You set roundingMode property as a name string of the rounding mode (such as 'ROUND_UP', 'ROUND_DOWN', etc.), see NumberLibRoundingMode.
  • The driver can infer rounding mode constants from the constructor or its properties, see below.
If not set, the driver will try to infer rounding mode constants by:
  1. Looking for an object containing these constants by checking properties RoundingModes and RoundingMode of the constructor and of the module (if specified). If not found assume the constructor itself contains the constants.
  2. Looking for properties with rounding mode names such as ROUND_UP, ROUND_DOWN, etc. in the object determined above, with and without ROUND_ prefix.

Note that you may also set RoundingModes to string in which case it will be used as a property name or path ('.'s allowed) of constructor or module to the object containing rounding mode constants instead of checking candidate names as described above.

The properties listed correspond to each rounding mode supported by the driver. Note that some number libraries, such as big.js, support only a subset of these. In this case the driver will infer all it can. If neither RoundingModes nor roundingMode properties are set and rounding mode constants cannot be inferred, the driver will assume default rounding mode ROUND_HALF_UP.

Note that some number libraries may support rounding modes not listed here and not supported by Java BigDecimal, such as ROUND_HALF_CEIL and ROUND_HALF_FLOOR. Using of these rounding modes will result in NoSQLArgumentError.

Although numeric rounding mode values are usually used, if the library of your choice using other type for rounding mode constants you may specify them as well. Any value is allowed except undefined and null.

Hierarchy

  • RoundingModesMap

Properties

CEILING?: unknown

Constant value for ROUND_CEILING rounding mode.

DOWN?: unknown

Constant value for ROUND_DOWN rounding mode.

FLOOR?: unknown

Constant value for ROUND_FLOOR rounding mode.

HALF_DOWN?: unknown

Constant value for ROUND_HALF_DOWN rounding mode.

HALF_EVEN?: unknown

Constant value for ROUND_HALF_EVEN rounding mode.

HALF_UP?: unknown

Constant value for ROUND_HALF_UP rounding mode.

UP?: unknown

Constant value for ROUND_UP rounding mode.

Generated using TypeDoc