Skip to content

$decimal

Returns a random BSON Decimal128 number.

Aliases: $decimal, $decimal128, $mgNumberDecimal

Options

  • min (optional) minimum value. Default 0.
  • max (optional) maximum value. Default 1000.
  • fixed (optional) number of digits after the decimal. Default 2.

Example

{
    "price": {
        "$decimal": {
            "fixed": 3
        }
    }
}
{
    "price": {
        "$numberDecimal": "545.241"
    }
}
{
    "price": NumberDecimal("545.241")
}