@@ -15,34 +15,30 @@ ObjectId
1515Description
1616-----------
1717
18- .. method:: ObjectId(<hexadecimal >)
18+ .. method:: ObjectId(<value >)
1919
20- Returns a new :ref:`objectid` value . The 12-byte :ref:`objectid`
21- value consists of:
20+ Returns a new :ref:`objectid`. The 12-byte :ref:`objectid` consists
21+ of:
2222
2323 .. include:: /includes/fact-ObjectId-construct.rst
2424
25- :method:`ObjectId()` can accept the following parameter :
25+ :method:`ObjectId()` can accept one of the following inputs :
2626
2727
2828 .. list-table::
2929 :header-rows: 1
30- :widths: 20 20 80
31-
32- * - Field
33-
34- - Type
30+ :widths: 20 80
3531
32+ * - Input Type
3633 - Description
3734
3835 * - ``hexadecimal``
39-
40- - String
41-
42- - Optional. A 24 character hexadecimal string value for the new ObjectId.
43-
44-
45-
36+ - Optional. A 24 character hexadecimal string value for the new
37+ ObjectId.
38+
39+ * - ``integer``
40+ - Optional. The integer value, in seconds, is added to the
41+ :wikipedia:`Unix epoch` to create the new timestamp.
4642
4743
4844Methods and Attributes
@@ -58,20 +54,13 @@ Methods and Attributes
5854 - Description
5955
6056 * - ``str``
61-
6257 - Returns the hexadecimal string representation of the object.
63-
6458 * - :method:`ObjectId.getTimestamp()`
65-
6659 - Returns the timestamp portion of the object as a Date.
67-
6860 * - :method:`ObjectId.toString()`
69-
7061 - Returns the JavaScript representation in the form of a string
7162 literal "``ObjectId(...)``".
72-
7363 * - :method:`ObjectId.valueOf()`
74-
7564 - Returns the representation of the object as a hexadecimal
7665 string. The returned string is the ``str`` attribute.
7766
@@ -87,7 +76,7 @@ To generate a new ObjectId, use :method:`ObjectId()` with no argument:
8776
8877 x = ObjectId()
8978
90- In this example, the value of ``x`` would be :
79+ In this example, the value of ``x`` is :
9180
9281.. code-block:: javascript
9382
@@ -124,6 +113,27 @@ This operation will return the following hexadecimal string:
124113
125114 507f191e810c19729de860ea
126115
116+ Specify an Integer String
117+ ~~~~~~~~~~~~~~~~~~~~~~~~~
118+
119+ Generate a new ObjectId using an integer.
120+
121+ .. code-block:: javascript
122+
123+ newObjectId = ObjectId(32)
124+
125+ The ObjectId resembles:
126+
127+ .. code-block:: javascript
128+
129+ ObjectId("00000020f51bb4362eee2a4d")
130+
131+ The first four bytes of the ObjectId are the number of seconds since
132+ the :wikipedia:`Unix epoch`. In this example ``32`` seconds,
133+ represented in hexadecimal as ``00000020``, are added. A five byte
134+ random element and a three byte counter make up the rest of the
135+ ObjectId.
136+
127137.. seealso::
128138
129139 :ref:`ObjectId BSON Type <objectid>`
0 commit comments