Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 87094fe

Browse files
committed
Add example on how to disable codec
1 parent 0037220 commit 87094fe

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎docs/tutorial/codecs.txt‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,24 @@ encoded will result in an exception. The ``aggregate``, ``find``, ``findOne``, `
117117
``findOneAndReplace``, and ``findOneAndUpdate`` operations will attempt to decode returned documents using the provided
118118
codec. If the codec does not support the data returned, an exception will be thrown. You can disable codec usage for a
119119
specific operation or use a different codec (e.g. to decode the result of an aggregation pipeline) by specifying the
120-
nullable ``codec`` option for the operation. This will override the collection-level codec.
120+
nullable ``codec`` option for the operation. This will override the collection-level codec:
121+
122+
.. code-block:: php
123+
124+
<?php
125+
126+
// Returns a document using the default type map
127+
$collection->findOne(['name' => 'Jane Doe'], [
128+
'codec' => null,
129+
]);
130+
131+
// Disables codec usage as the aggregate result will have a different format
132+
$collection->aggregate([['$group' => [
133+
'_id' => '$accountType',
134+
'count' => ['$sum' => 1],
135+
]]], [
136+
'codec' => null,
137+
]);
121138

122139
Generic Codecs
123140
--------------

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /