reference/mongodb/bson/objectid.xml
d120d37cc9ab821759a059f510807bb6e79462fb
...
...
@@ -3,17 +3,39 @@
3
3

4
4
<phpdoc:classref xml:id="class.mongodb-bson-objectid" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
5
5

6
-
<title>The MongoDB\BSON\ObjectID class</title>
7
-
<titleabbrev>MongoDB\BSON\ObjectID</titleabbrev>
6
+
<title>The MongoDB\BSON\ObjectId class</title>
7
+
<titleabbrev>MongoDB\BSON\ObjectId</titleabbrev>
8
8

9
9
<partintro>
10
10

11
-
<!-- {{{ MongoDB\BSON\ObjectID intro -->
11
+
<!-- {{{ MongoDB\BSON\ObjectId intro -->
12
12
<section xml:id="mongodb-bson-objectid.intro">
13
13
&reftitle.intro;
14
14
<para>
15
-

15
+
BSON type for an
16
+
<link xlink:href="&url.mongodb.docs.bson;#objectid">ObjectId</link>. The
17
+
value consists of 12 bytes, where the first four bytes are a timestamp
18
+
that reflect the ObjectId's creation. Specifically, the value consists of:
19
+
</para>
20
+
<itemizedlist>
21
+
<listitem><simpara>a 4-byte value representing the seconds since the Unix epoch,</simpara></listitem>
22
+
<listitem><simpara>a 5-byte random number unique to a machine and process, and</simpara></listitem>
23
+
<listitem><simpara>a 3-byte counter, starting with a random value.</simpara></listitem>
24
+
</itemizedlist>
25
+
<para>
26
+
In MongoDB, each document stored in a collection requires a unique
27
+
<literal>_id</literal> field that acts as a primary key. If an inserted
28
+
document omits the <literal>_id</literal> field, the driver automatically
29
+
generates an ObjectId for the <literal>_id</literal> field.
16
30
</para>
31
+
<para>
32
+
Using ObjectIds for the <literal>_id</literal> field provides the following
33
+
additional benefits:
34
+
</para>
35
+
<itemizedlist>
36
+
<listitem><simpara>The creation time of the ObjectId may be accessed using the <methodname>MongoDB\BSON\ObjectId::getTimestamp</methodname> method.</simpara></listitem>
37
+
<listitem><simpara>Sorting on an <literal>_id</literal> field that stores ObjectId values is roughly equivalent to sorting by creation time.</simpara></listitem>
38
+
</itemizedlist>
17
39
</section>
18
40
<!-- }}} -->
19
41

...
...
@@ -22,17 +44,34 @@
22
44

23
45
<!-- {{{ Synopsis -->
24
46
<classsynopsis>
25
-
<ooclass><classname>MongoDB\BSON\ObjectID</classname></ooclass>
47
+
<ooclass><classname>MongoDB\BSON\ObjectId</classname></ooclass>
26
48

27
49
<!-- {{{ Class synopsis -->
28
50
<classsynopsisinfo>
51
+
<modifier>final</modifier>
29
52
<ooclass>
30
-
<classname>MongoDB\BSON\ObjectID</classname>
53
+
<classname>MongoDB\BSON\ObjectId</classname>
31
54
</ooclass>
32
55

33
56
<oointerface>
57
+
<interfacename>MongoDB\BSON\ObjectIdInterface</interfacename>
58
+
</oointerface>
59
+

60
+
<oointerface>
34
61
<interfacename>MongoDB\BSON\Type</interfacename>
35
62
</oointerface>
63
+

64
+
<oointerface>
65
+
<interfacename>Serializable</interfacename>
66
+
</oointerface>
67
+

68
+
<oointerface>
69
+
<interfacename>JsonSerializable</interfacename>
70
+
</oointerface>
71
+

72
+
<oointerface>
73
+
<interfacename>Stringable</interfacename>
74
+
</oointerface>
36
75
</classsynopsisinfo>
37
76
<!-- }}} -->
38
77
...
...
@@ -43,6 +82,49 @@
43
82

44
83
</section>
45
84

85
+
<section role="changelog">
86
+
&reftitle.changelog;
87
+
<para>
88
+
<informaltable>
89
+
<tgroup cols="2">
90
+
<thead>
91
+
<row>
92
+
<entry>&Version;</entry>
93
+
<entry>&Description;</entry>
94
+
</row>
95
+
</thead>
96
+
<tbody>
97
+
<row>
98
+
<entry>PECL mongodb 1.12.0</entry>
99
+
<entry>
100
+
Implements <interfacename>Stringable</interfacename> for PHP 8.0+.
101
+
</entry>
102
+
</row>
103
+
<row>
104
+
<entry>PECL mongodb 1.3.0</entry>
105
+
<entry>
106
+
<para>
107
+
Renamed from <literal>MongoDB\BSON\ObjectID</literal> to
108
+
<literal>MongoDB\BSON\ObjectId</literal>.
109
+
</para>
110
+
<para>
111
+
Implements <interfacename>MongoDB\BSON\ObjectIdInterface</interfacename>.
112
+
</para>
113
+
</entry>
114
+
</row>
115
+
<row>
116
+
<entry>PECL mongodb 1.2.0</entry>
117
+
<entry>
118
+
Implements <interfacename>Serializable</interfacename> and
119
+
<interfacename>JsonSerializable</interfacename>.
120
+
</entry>
121
+
</row>
122
+
</tbody>
123
+
</tgroup>
124
+
</informaltable>
125
+
</para>
126
+
</section>
127
+

46
128
</partintro>
47
129

48
130
&reference.mongodb.bson.entities.objectid;
49
131