@@ -19,15 +19,209 @@ Definition
1919
2020 .. code-block:: php
2121
22- function find(array|object $filter = [], array $options = []): MongoDB\Driver\Cursor
22+ function find(
23+ array|object $filter = [],
24+ array $options = []
25+ ): MongoDB\Driver\Cursor
2326
24- This method has the following parameters:
27+ Parameters
28+ ----------
29+
30+ ``$filter`` : array|object
31+ The filter criteria that specifies the documents to query.
32+
33+ ``$options`` : array
34+ An array specifying the desired options.
35+
36+ .. list-table::
37+ :header-rows: 1
38+ :widths: 20 20 80
39+
40+ * - Name
41+ - Type
42+ - Description
43+
44+ * - allowDiskUse
45+ - boolean
46+ - Enables writing to temporary files. When set to ``true``, queries can
47+ write data to the ``_tmp`` sub-directory in the ``dbPath`` directory.
48+
49+ * - allowPartialResults
50+ - boolean
51+ - For queries against a sharded collection, returns partial results from
52+ the :program:`mongos` if some shards are unavailable instead of
53+ throwing an error.
54+
55+ * - batchSize
56+ - integer
57+ - The number of documents to return in the first batch. Defaults to
58+ ``101``. A batchSize of ``0`` means that the cursor will be
59+ established, but no documents will be returned in the first batch.
60+
61+ Unlike the previous wire protocol version, a batchSize of ``1`` for the
62+ :dbcommand:`find` command does not close the cursor.
63+
64+ * - collation
65+ - array|object
66+ - .. include:: /includes/extracts/common-option-collation.rst
67+
68+ * - comment
69+ - mixed
70+ - .. include:: /includes/extracts/common-option-comment.rst
71+
72+ The comment can be any valid BSON type for server versions 4.4 and above.
73+ Earlier server versions only support string values.
74+
75+ * - cursorType
76+ - integer
77+ - Indicates the type of cursor to use. ``cursorType`` supports the
78+ following values:
79+
80+ - ``MongoDB\Operation\Find::NON_TAILABLE`` (*default*)
81+ - ``MongoDB\Operation\Find::TAILABLE``
82+
83+ * - hint
84+ - string|array|object
85+ - .. include:: /includes/extracts/common-option-hint.rst
86+
87+ .. versionadded:: 1.2
88+
89+ * - let
90+ - array|object
91+ - .. include:: /includes/extracts/common-option-let.rst
92+
93+ .. versionadded:: 1.13
94+
95+ * - limit
96+ - integer
97+ - The maximum number of documents to return. If unspecified, then
98+ defaults to no limit. A limit of ``0`` is equivalent to setting no
99+ limit.
100+
101+ A negative limit is similar to a positive limit but closes the cursor
102+ after returning a single batch of results. As such, with a negative
103+ limit, if the limited result set does not fit into a single batch, the
104+ number of documents received will be less than the specified limit. By
105+ passing a negative limit, the client indicates to the server that it
106+ will not ask for a subsequent batch via getMore.
107+
108+ * - max
109+ - array|object
110+ - The exclusive upper bound for a specific index.
111+
112+ .. versionadded:: 1.2
113+
114+ * - maxAwaitTimeMS
115+ - integer
116+ - Positive integer denoting the time limit in milliseconds for the server
117+ to block a getMore operation if no data is available. This option
118+ should only be used if cursorType is TAILABLE_AWAIT.
119+
120+ .. versionadded:: 1.2
121+
122+ * - maxScan
123+ - integer
124+ - Maximum number of documents or index keys to scan when executing the
125+ query.
126+
127+ .. deprecated:: 1.4
128+ .. versionadded:: 1.2
129+
130+ * - maxTimeMS
131+ - integer
132+ - .. include:: /includes/extracts/common-option-maxTimeMS.rst
133+
134+ * - min
135+ - array|object
136+ - The inclusive lower bound for a specific index.
137+
138+ .. versionadded:: 1.2
139+
140+ * - modifiers
141+ - array|object
142+ - :manual:`Meta operators </reference/operator/query-modifier>` that
143+ modify the output or behavior of a query. Use of these operators is
144+ deprecated in favor of named options.
145+
146+ * - noCursorTimeout
147+ - boolean
148+ - Prevents the server from timing out idle cursors after an inactivity
149+ period (10 minutes).
150+
151+ * - oplogReplay
152+ - boolean
153+ - Internal use for replica sets. To use ``oplogReplay``, you must include
154+ the following condition in the filter:
155+
156+ .. code-block:: javascript
157+
158+ { ts: { $gte: <timestamp> } }
159+
160+ The :php:`MongoDB\\BSON\\Timestamp <class.mongodb-bson-timestamp>`
161+ class reference describes how to represent MongoDB's BSON timestamp
162+ type with PHP.
163+
164+ .. deprecated:: 1.7
165+
166+ * - projection
167+ - array|object
168+ - The :ref:`projection specification <projections>` to determine which
169+ fields to include in the returned documents. See
170+ :manual:`Project Fields to Return from Query </tutorial/project-fields-from-query-results>`
171+ and :manual:`Projection Operators </reference/operator/projection>` in
172+ the MongoDB manual.
173+
174+ * - readConcern
175+ - :php:`MongoDB\\Driver\\ReadConcern <class.mongodb-driver-readconcern>`
176+ - .. include:: /includes/extracts/bucket-option-readConcern.rst
177+
178+ It is not possible to specify a :manual:`read concern
179+ </reference/read-concern>` for individual operations as part of a
180+ transaction. Instead, set the ``readConcern`` option when starting the
181+ transaction with :php:`startTransaction <mongodb-driver-session.starttransaction>`.
182+
183+ * - readPreference
184+ - :php:`MongoDB\\Driver\\ReadPreference <class.mongodb-driver-readpreference>`
185+ - .. include:: /includes/extracts/bucket-option-readPreference.rst
186+
187+ * - returnKey
188+ - boolean
189+ - If true, returns only the index keys in the resulting documents.
190+
191+ .. versionadded:: 1.2
192+
193+ * - session
194+ - :php:`MongoDB\\Driver\\Session <class.mongodb-driver-session>`
195+ - .. include:: /includes/extracts/common-option-session.rst
196+
197+ .. versionadded:: 1.3
198+
199+ * - showRecordId
200+ - boolean
201+ - Determines whether to return the record identifier for each document.
202+ If true, adds a field ``$recordId`` to the returned documents.
203+
204+ .. versionadded:: 1.2
205+
206+ * - skip
207+ - integer
208+ - Number of documents to skip. Defaults to ``0``.
209+
210+ * - sort
211+ - array|object
212+ - The sort specification for the ordering of the results.
25213
26- .. include:: /includes/apiargs/MongoDBCollection-method-find-param.rst
214+ * - snapshot
215+ - boolean
216+ - Prevents the cursor from returning a document more than once because of
217+ an intervening write operation.
27218
28- The ``$options`` parameter supports the following options:
219+ .. deprecated:: 1.4
220+ .. versionadded:: 1.2
29221
30- .. include:: /includes/apiargs/MongoDBGridFSBucket-method-find-option.rst
222+ * - typeMap
223+ - array
224+ - .. include:: /includes/extracts/bucket-option-typeMap.rst
31225
32226Return Values
33227-------------
0 commit comments