Skip to content

Commit b480d57

Browse files
author
Dave Cuthbert
authored
DOCSP-23190 BACKPORT (#1257)
1 parent ba3dee7 commit b480d57

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

source/tutorial/model-monetary-data.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,32 @@ Numeric Model
7777
Using the Decimal BSON Type
7878
~~~~~~~~~~~~~~~~~~~~~~~~~~~
7979

80-
The ``decimal`` :doc:`BSON type </reference/bson-types>` uses the
81-
IEEE 754 decimal128 decimal-based floating-point numbering format.
82-
Unlike binary-based floating-point formats (i.e., the ``double`` BSON
83-
type), decimal128 does not approximate decimal values and is able to
80+
The ``decimal128`` :ref:`BSON type <bson-types>` uses the IEEE 754
81+
``decimal128`` decimal-based floating-point numbering format. Unlike
82+
binary-based floating-point formats such as the ``double`` BSON type,
83+
``decimal128`` does not approximate decimal values and is able to
8484
provide the exact precision required for working with monetary data.
8585

86-
From :binary:`~bin.mongosh` ``decimal`` values are assigned and
87-
queried using the ``NumberDecimal()`` constructor. The following
88-
example adds a document containing gas prices to a ``gasprices``
89-
collection:
86+
In :binary:`~bin.mongosh`, ``decimal`` values are assigned and queried
87+
using the ``Decimal128()`` constructor. The following example adds a
88+
document containing gas prices to a ``gasprices`` collection:
9089

9190
.. code-block:: javascript
9291

93-
db.gasprices.insert{ "_id" : 1, "date" : ISODate(), "price" : NumberDecimal("2.099"), "station" : "Quikstop", "grade" : "regular" }
94-
92+
db.gasprices.insertOne(
93+
{
94+
"date" : ISODate(),
95+
"price" : Decimal128("2.099"),
96+
"station" : "Quikstop",
97+
"grade" : "regular"
98+
}
99+
)
100+
95101
The following query matches the document above:
96102

97103
.. code-block:: javascript
98104

99-
db.gasprices.find( { price: NumberDecimal("2.099") } )
105+
db.gasprices.find( { price: Decimal128("2.099") } )
100106

101107
For more information on the ``decimal`` type, see
102108
:ref:`shell-type-decimal`.
@@ -112,7 +118,7 @@ to perform the transformation as it accesses records.
112118

113119
Alternative to the procedure outlined below, starting in version
114120
4.0, you can use the :expression:`$convert` and its helper
115-
:expression:`$toDecimal` operator to convert values to ``NumberDecimal()``.
121+
:expression:`$toDecimal` operator to convert values to ``Decimal128()``.
116122

117123
One-Time Collection Transformation
118124
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)