|
1 | 1 | # Usage
|
2 | 2 |
|
| 3 | +## Client class |
| 4 | + |
| 5 | +`MongoDB\Client` serves as an entry point for the library and driver. It is |
| 6 | +constructed with the same arguments as the driver's `MongoDB\Driver\Manager` |
| 7 | +class, which it composes. The Client class provides methods for creating a |
| 8 | +Database or Collection class (from the internal manager instance), as well as |
| 9 | +top-level operations, such as enumerating and dropping databases. |
| 10 | + |
3 | 11 | ## Collection class
|
4 | 12 |
|
5 | 13 | `MongoDB\Collection` is perhaps the most useful class in this library. It
|
6 | 14 | provides methods for common operations on a collection, such as inserting
|
7 | 15 | documents, querying, updating, counting, etc.
|
8 | 16 |
|
9 |
| -Constructing a `MongoDB\Collection` requires a `MongoDB\Manager` and a namespace |
10 |
| -for the collection. A [MongoDB namespace](http://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace) |
| 17 | +Constructing a `MongoDB\Collection` requires a `MongoDB\Driver\Manager` and a |
| 18 | +namespace for the collection. A [MongoDB namespace](http://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace) |
11 | 19 | consists of a database name and collection name joined by a dot. `examples.zips`
|
12 |
| -is on example of a namespace. A [write concern](http://docs.mongodb.org/manual/core/write-concern/) |
| 20 | +is one example of a namespace. Through normal use of the library, a Collection |
| 21 | +will typically be created via the `selectCollection()` method on the Manager or |
| 22 | +Database classes. |
| 23 | + |
| 24 | +A [write concern](http://docs.mongodb.org/manual/core/write-concern/) |
13 | 25 | and [read preference](http://docs.mongodb.org/manual/core/read-preference/) may
|
14 |
| -also be provided when constructing a Collection (if omitted, the Collection will |
15 |
| -use the Manager's values as its defaults). |
| 26 | +also be provided when constructing a Collection. If these options are omitted, |
| 27 | +the Collection will inherit them from the parent through which it was selected, |
| 28 | +or the Manager. |
16 | 29 |
|
17 |
| -## Finding a specific document |
| 30 | +### Finding a specific document |
18 | 31 |
|
19 | 32 | ```
|
20 | 33 | <?php
|
@@ -51,3 +64,14 @@ array(5) {
|
51 | 64 | string(2) "CA"
|
52 | 65 | }
|
53 | 66 | ```
|
| 67 | + |
| 68 | +## Database class |
| 69 | + |
| 70 | +`MongoDB\Database` provides methods for common operations on a database, such |
| 71 | +as creating, enumerating, and dropping collections. |
| 72 | + |
| 73 | +A [write concern](http://docs.mongodb.org/manual/core/write-concern/) |
| 74 | +and [read preference](http://docs.mongodb.org/manual/core/read-preference/) may |
| 75 | +also be provided when constructing a Database. If these options are omitted, |
| 76 | +the Database will inherit them from the Client through which it was selected, |
| 77 | +or the Manager. |
0 commit comments