File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -60,17 +60,34 @@ Starting in 1.8.0, the ``ObjectId`` wrapper no longer accepts:
60
60
61
61
:method:`ObjectId`
62
62
63
+ Double
64
+ ------
65
+
66
+ The :node-api:`Double() <Double.html>` constructor can be used to
67
+ explicitly specify a double:
68
+
69
+ .. code-block:: javascript
70
+
71
+ db.types.insertOne(
72
+ {
73
+ "_id": 2,
74
+ "value": Double(1),
75
+ "expectedType": "Double"
76
+ }
77
+ )
78
+
79
+ .. note::
80
+
81
+ If field's value is a number that can be converted to a 32-bit integer,
82
+ ``mongosh`` will store it as ``Int32``. If not, ``mongosh`` defaults to
83
+ storing the number as a ``Double``. To specify the value type, use the
84
+ ``Double()`` or ``Int32()`` constructors.
85
+
63
86
.. _shell-type-int:
64
87
65
88
Int32
66
89
-----
67
90
68
- If a number can be converted to a 32-bit integer, ``mongosh`` will
69
- store it as ``Int32``. If not, ``mongosh`` defaults to storing the
70
- number as a ``Double``. Numerical values that are stored as ``Int32``
71
- in ``mongosh`` would have been stored by default as ``Double`` in the
72
- ``mongo`` shell.
73
-
74
91
The :node-api:`Int32() <Int32.html>` constructor can be used to
75
92
explicitly specify 32-bit integers.
76
93
@@ -79,7 +96,7 @@ explicitly specify 32-bit integers.
79
96
db.types.insertOne(
80
97
{
81
98
"_id": 1,
82
- "value": Int32("1" ),
99
+ "value": Int32(1 ),
83
100
"expectedType": "Int32"
84
101
}
85
102
)
@@ -103,7 +120,7 @@ explicitly specify a 64-bit integer.
103
120
db.types.insertOne(
104
121
{
105
122
"_id": 3,
106
- "value": Long("1" ),
123
+ "value": Long(1 ),
107
124
"expectedType": "Long"
108
125
}
109
126
)
You can’t perform that action at this time.
0 commit comments