File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,38 @@ Write Preference Behavior
128
128
legacy :binary:`mongo` shell. To disable retryable writes, use
129
129
:option:`--retryWrites=false <mongosh --retryWrites>`.
130
130
131
+
132
+ ObjectId Methods and Attributes
133
+ -------------------------------
134
+
135
+ These :ref:`ObjectId() <server-objectid>` methods work differently in
136
+ ``mongosh`` than in the legacy ``mongo`` shell.
137
+
138
+ .. list-table::
139
+ :header-rows: 1
140
+
141
+ * - Method or Attribute
142
+ - ``mongo`` Behavior
143
+ - ``mongosh`` Behavior
144
+
145
+ * - ``ObjectId.str``
146
+ - | Returns a hexadecimal string:
147
+ | ``6419ccfce40afaf9317567b7``
148
+ - | Undefined
149
+ | (Not available)
150
+
151
+ * - ``ObjectId.valueOf()``
152
+ - | Returns the value of ``ObjectId.str``:
153
+ | ``6419ccfce40afaf9317567b7``
154
+ - | Returns the value of ``ObjectId.self``:
155
+ | ``ObjectId("6419ccfce40afaf9317567b7")``
156
+
157
+ * - ``ObjectId.toString()``
158
+ - | Returns a formatted string:
159
+ | ``ObjectId("6419ccfce40afaf9317567b7")``
160
+ - | Returns a hexadecimal formatted string:
161
+ | ``6419ccfce40afaf9317567b7``
162
+
131
163
Numeric Values
132
164
--------------
133
165
You can’t perform that action at this time.
0 commit comments