Skip to content

Commit 5080b80

Browse files
committed
Rename persistence tutorial and move sections around
1 parent f57e728 commit 5080b80

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

docs/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ following pages should help you get started:
3535

3636
- :doc:`/tutorial/gridfs`
3737

38-
- :doc:`/tutorial/persistable-classes`
38+
- :doc:`/tutorial/modeling-bson-data`
3939

4040
- :doc:`/reference/bson`
4141

docs/tutorial.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ Tutorials
1717
/tutorial/indexes
1818
/tutorial/tailable-cursor
1919
/tutorial/example-data
20-
/tutorial/persistable-classes
20+
/tutorial/modeling-bson-data
2121
/tutorial/stable-api

docs/tutorial/persistable-classes.txt renamed to docs/tutorial/modeling-bson-data.txt

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
===================
2-
Persistable classes
3-
===================
1+
==================
2+
Modeling BSON Data
3+
==================
44

55
.. default-domain:: mongodb
66

@@ -11,6 +11,45 @@ Persistable classes
1111
:class: singlecol
1212

1313

14+
Type Maps
15+
---------
16+
17+
Most methods that read data from MongoDB support a ``typeMap`` option, which
18+
allows control over how BSON is converted to PHP. Additionally,
19+
the :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
20+
:phpclass:`MongoDB\\Collection` classes accept a ``typeMap`` option, which can
21+
be used to specify a default type map to apply to any supporting methods and
22+
selected classes (e.g. :phpmethod:`MongoDB\\Client::selectDatabase()`).
23+
24+
The :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
25+
:phpclass:`MongoDB\\Collection` classes use the following type map by
26+
default:
27+
28+
.. code-block:: php
29+
30+
[
31+
'array' => 'MongoDB\Model\BSONArray',
32+
'document' => 'MongoDB\Model\BSONDocument',
33+
'root' => 'MongoDB\Model\BSONDocument',
34+
]
35+
36+
The type map above will convert BSON documents and arrays to
37+
:phpclass:`MongoDB\\Model\\BSONDocument` and
38+
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The ``root`` and
39+
``document`` keys are used to distinguish the top-level BSON document from
40+
embedded documents, respectively.
41+
42+
A type map may specify any class that implements
43+
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>` as well as
44+
``"array"``, ``"stdClass``", and ``"object"`` (``"stdClass``" and ``"object"``
45+
are aliases of one another).
46+
47+
.. seealso:: :php:`Deserialization from BSON <manual/en/mongodb.persistence.deserialization.php>` in the PHP manual
48+
49+
50+
Persistable Classes
51+
-------------------
52+
1453
The driver's :php:`persistence specification <mongodb.persistence>` outlines how
1554
classes implementing its :php:`MongoDB\\BSON\\Persistable
1655
<mongodb-bson-persistable>` interface are serialized to and deserialized from
@@ -117,38 +156,3 @@ The same document in the MongoDB shell might display as:
117156
:php:`MongoDB\\BSON\\Persistable <mongodb-bson-persistable>` may only be used
118157
for root and embedded BSON documents. It may not be used for BSON arrays.
119158
.. _php-type-map:
120-
121-
Type Maps
122-
---------
123-
124-
Most methods that read data from MongoDB support a ``typeMap`` option, which
125-
allows control over how BSON is converted to PHP. Additionally,
126-
the :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
127-
:phpclass:`MongoDB\\Collection` classes accept a ``typeMap`` option, which can
128-
be used to specify a default type map to apply to any supporting methods and
129-
selected classes (e.g. :phpmethod:`MongoDB\\Client::selectDatabase()`).
130-
131-
The :phpclass:`MongoDB\\Client`, :phpclass:`MongoDB\\Database`, and
132-
:phpclass:`MongoDB\\Collection` classes use the following type map by
133-
default:
134-
135-
.. code-block:: php
136-
137-
[
138-
'array' => 'MongoDB\Model\BSONArray',
139-
'document' => 'MongoDB\Model\BSONDocument',
140-
'root' => 'MongoDB\Model\BSONDocument',
141-
]
142-
143-
The type map above will convert BSON documents and arrays to
144-
:phpclass:`MongoDB\\Model\\BSONDocument` and
145-
:phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The ``root`` and
146-
``document`` keys are used to distinguish the top-level BSON document from
147-
embedded documents, respectively.
148-
149-
A type map may specify any class that implements
150-
:php:`MongoDB\\BSON\\Unserializable <mongodb-bson-unserializable>` as well as
151-
``"array"``, ``"stdClass``", and ``"object"`` (``"stdClass``" and ``"object"``
152-
are aliases of one another).
153-
154-
.. seealso:: :php:`Deserialization from BSON <manual/en/mongodb.persistence.deserialization.php>` in the PHP manual

0 commit comments

Comments
 (0)