Skip to content

Commit b2ebd03

Browse files
authored
DOCSP 23275 updating toString method (#1422) (#1431)
* DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 improving ObjectId.toString() example * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 updating toStringmethod * DOCSP-23275 JavaScript typo * DOCSP-23275 fixing variable
1 parent 230929f commit b2ebd03

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

source/reference/method/ObjectId.toString.txt

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,44 @@ ObjectId.toString()
1212

1313
.. method:: ObjectId.toString()
1414

15-
Returns the string representation of the :method:`ObjectId()`. This
16-
string value has the format of ``ObjectId(...)``.
15+
Returns the string representation of the :method:`ObjectId()`.
1716

1817
Example
1918
-------
2019

21-
The following example calls the :method:`~ObjectId.toString()` method
22-
on an :method:`ObjectId()` instance in :binary:`~bin.mongosh`:
20+
The following example:
21+
22+
- Generates a new :method:`ObjectId()` and stores it in the
23+
variable ``myObjectId``.
24+
25+
- Creates a string representation of ``myObjectId`` using
26+
the :method:`toString()<ObjectId.toString()>` method.
27+
28+
- Stores the string representation in the variable ``myObjectIdString``.
29+
30+
Run the following commands in :binary:`mongosh`:
31+
32+
.. code-block:: javascript
33+
34+
myObjectId = ObjectId("507c7f79bcf86cd7994f6c0e")
35+
myObjectIdString = myObjectId.toString()
36+
37+
The operation returns the following string:
2338

2439
.. code-block:: javascript
40+
:copyable: false
2541

26-
ObjectId("507c7f79bcf86cd7994f6c0e").toString()
42+
507c7f79bcf86cd7994f6c0e
2743

28-
This will return the following string:
44+
To confirm the type of ``myObjectIdString``, use the ``typeof`` JavaScript operator:
2945

3046
.. code-block:: javascript
3147

32-
ObjectId("507c7f79bcf86cd7994f6c0e")
48+
typeof myObjectIdString
3349

34-
You can confirm the type of this object using the following
35-
operation:
50+
The operation returns the following:
3651

3752
.. code-block:: javascript
53+
:copyable: false
3854

39-
typeof ObjectId("507c7f79bcf86cd7994f6c0e").toString()
55+
string

0 commit comments

Comments
 (0)