reference/mongodb/tutorial/library.xml
077667aa60c2eaee4fbb704824e265d3ad6120b3
...
...
@@ -29,7 +29,7 @@
29
29
Install the library by running:
30
30
<programlisting role="shell">
31
31
<![CDATA[
32
-
$ composer require "mongodb/mongodb=^1.0.0"
32
+
$ composer require mongodb/mongodb
33
33
]]>
34
34
</programlisting>
35
35
</para>
...
...
@@ -77,24 +77,20 @@ require 'vendor/autoload.php';
77
77

78
78
<para>
79
79
With this done, you can now use any of the functionality as described in the
80
-
<link xlink:href="&url.mongodb.library.docs;">library documentation</link>
81
-
and its <link xlink:href="&url.mongodb.library.apidocs;">API</link>.
80
+
<link xlink:href="&url.mongodb.library.docs;">library documentation</link>.
82
81
</para>
83
82

84
83
<para>
85
-
If you have previously used the old driver (i.e. <code>mongo</code>
86
-
extension), the library's API should look familiar. It contains a
87
-
<link xlink:href="&url.mongodb.library.apidocs;/class-MongoDB.Client.html">Client</link>
88
-
class for connecting to MongoDB, and
89
-
<link xlink:href="&url.mongodb.library.apidocs;/class-MongoDB.Database.html">Database</link>
90
-
class for database-level operations (e.g. commands, collection management)
84
+
If you have used MongoDB drivers in other languages, the library's API
85
+
should look familiar. It contains a
86
+
<link xlink:href="&url.mongodb.library.apidocs;/class/MongoDBClient/">Client</link>
87
+
class for connecting to MongoDB, a
88
+
<link xlink:href="&url.mongodb.library.apidocs;/class/MongoDBDatabase/">Database</link>
89
+
class for database-level operations (e.g. commands, collection management),
91
90
and a
92
-
<link xlink:href="&url.mongodb.library.apidocs;/class-MongoDB.Collection.html">Collection</link>
91
+
<link xlink:href="&url.mongodb.library.apidocs;/class/MongoDBCollection">Collection</link>
93
92
class for collection-level operations (e.g.
94
93
<link xlink:href="&url.mongodb.wiki.crud;">CRUD</link> methods, index management).
95
-
Various Collection methods have been renamed for clarity, and to be in
96
-
accordance with a new language-agnostic
97
-
<link xlink:href="&url.mongodb.crud;">specification</link>.
98
94
</para>
99
95

100
96
<para>
...
...
@@ -104,7 +100,7 @@ require 'vendor/autoload.php';
104
100
<programlisting role="php">
105
101
<![CDATA[
106
102
<?php
107
-
require 'vendor/autoload.php'; // include Composer goodies
103
+
require 'vendor/autoload.php'; // include Composer's autoloader
108
104

109
105
$client = new MongoDB\Client("mongodb://localhost:27017");
110
106
$collection = $client->demo->beers;
...
...
@@ -118,19 +114,21 @@ echo "Inserted with Object ID '{$result->getInsertedId()}'";
118
114
</para>
119
115

120
116
<para>
121
-
Instead of injecting the generated <code>_id</code> field into the input
122
-
document (as was done in the old driver), it is now made available through
123
-
the result object returned by the <code>insertOne</code> method.
117
+
Since the inserted document did not contain an <code>_id</code> field, the
118
+
driver will generate an <classname>MongoDB\BSON\ObjectId</classname> for the
119
+
server to use as the <code>_id</code>. This value is also made available to
120
+
the caller via the result object returned by the <code>insertOne</code>
121
+
method.
124
122
</para>
125
123

126
124
<para>
127
-
After insertion, you can of course also query the data that you have just
128
-
inserted. For that, you use the <code>find</code> method, which returns an
129
-
iterable cursor:
125
+
After insertion, you can query for the data that you have just inserted.
126
+
For that, you use the <code>find</code> method, which returns an iterable
127
+
cursor:
130
128
<programlisting role="php">
131
129
<![CDATA[
132
130
<?php
133
-
require 'vendor/autoload.php'; // include Composer goodies
131
+
require 'vendor/autoload.php'; // include Composer's autoloader
134
132

135
133
$client = new MongoDB\Client("mongodb://localhost:27017");
136
134
$collection = $client->demo->beers;
...
...
@@ -150,7 +148,7 @@ foreach ($result as $entry) {
150
148
unserialized as type classes in the library by default. These classes ensure
151
149
that values preserve their type when being serialized back into BSON, which
152
150
avoids a caveat in the old driver where arrays might turn into documents,
153
-
and vice versa. Additionally, the classes extend
151
+
and vice versa. Additionally, these type classes extend
154
152
<classname>ArrayObject</classname> for enhanced usability. You can find more
155
153
information on how serialization and deserialization between PHP variables
156
154
and BSON is handled by the driver and library by reading the
157
155