Skip to content

Commit 0bcd914

Browse files
author
Dave Cuthbert
authored
DOCSP-28696 mongosh updates for server ticket (#251)
* DOCSP-28696 mongosh updates for server ticket * Review feedback * Staging fixes * Staging fixes * Staging fixes * Staging fixes
1 parent 985f53a commit 0bcd914

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

source/reference/compatibility.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,38 @@ Write Preference Behavior
128128
legacy :binary:`mongo` shell. To disable retryable writes, use
129129
:option:`--retryWrites=false <mongosh --retryWrites>`.
130130

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+
131163
Numeric Values
132164
--------------
133165

0 commit comments

Comments
 (0)