A class representation of the BSON Decimal128 type.

Hierarchy

Constructors

Properties

bytes: Uint8Array
_fromString: any

Accessors

  • get _bsontype(): "Decimal128"
  • Returns "Decimal128"

Methods

  • Returns string

  • Create a string representation of the raw Decimal128 value

    Returns string

  • Create a Decimal128 instance from a string representation

    Parameters

    • representation: string

      a numeric string representation.

    Returns mongoose.mongo.BSON.Decimal128

  • Create a Decimal128 instance from a string representation, allowing for rounding to 34 significant digits

    Parameters

    • representation: string

      a numeric string representation.

    Returns mongoose.mongo.BSON.Decimal128

    Example

    Example of a number that will be rounded

    > let d = Decimal128.fromString('37.499999999999999196428571428571375')
    Uncaught:
    BSONError: "37.499999999999999196428571428571375" is not a valid Decimal128 string - inexact rounding
    at invalidErr (/home/wajames/js-bson/lib/bson.cjs:1402:11)
    at Decimal128.fromStringInternal (/home/wajames/js-bson/lib/bson.cjs:1633:25)
    at Decimal128.fromString (/home/wajames/js-bson/lib/bson.cjs:1424:27)

    > d = Decimal128.fromStringWithRounding('37.499999999999999196428571428571375')
    new Decimal128("37.49999999999999919642857142857138")

Generated using TypeDoc