@@ -76,10 +76,17 @@ class Find implements Executable
76
76
*
77
77
* * limit (integer): The maximum number of documents to return.
78
78
*
79
+ * * max (document): The exclusive upper bound for a specific index.
80
+ *
81
+ * * maxScan (integer): Maximum number of documents or index keys to scan
82
+ * when executing the query.
83
+ *
79
84
* * maxTimeMS (integer): The maximum amount of time to allow the query to
80
85
* run. If "$maxTimeMS" also exists in the modifiers document, this
81
86
* option will take precedence.
82
87
*
88
+ * * min (document): The inclusive upper bound for a specific index.
89
+ *
83
90
* * modifiers (document): Meta operators that modify the output or
84
91
* behavior of a query. Use of these operators is deprecated in favor of
85
92
* named options.
@@ -101,8 +108,18 @@ class Find implements Executable
101
108
*
102
109
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
103
110
*
111
+ * * returnKey (boolean): If true, returns only the index keys in the
112
+ * resulting documents.
113
+ *
114
+ * * showRecordId (boolean): Determines whether to return the record
115
+ * identifier for each document. If true, adds a field $recordId to the
116
+ * returned documents.
117
+ *
104
118
* * skip (integer): The number of documents to skip before returning.
105
119
*
120
+ * * snapshot (boolean): Prevents the cursor from returning a document more
121
+ * than once because of an intervening write operation.
122
+ *
106
123
* * sort (document): The order in which to return matching documents. If
107
124
* "$orderby" also exists in the modifiers document, this option will
108
125
* take precedence.
@@ -158,10 +175,22 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
158
175
throw InvalidArgumentException::invalidType ('"limit" option ' , $ options ['limit ' ], 'integer ' );
159
176
}
160
177
178
+ if (isset ($ options ['max ' ]) && ! is_array ($ options ['max ' ]) && ! is_object ($ options ['max ' ])) {
179
+ throw InvalidArgumentException::invalidType ('"max" option ' , $ options ['max ' ], 'array or object ' );
180
+ }
181
+
182
+ if (isset ($ options ['maxScan ' ]) && ! is_integer ($ options ['maxScan ' ])) {
183
+ throw InvalidArgumentException::invalidType ('"maxScan" option ' , $ options ['maxScan ' ], 'integer ' );
184
+ }
185
+
161
186
if (isset ($ options ['maxTimeMS ' ]) && ! is_integer ($ options ['maxTimeMS ' ])) {
162
187
throw InvalidArgumentException::invalidType ('"maxTimeMS" option ' , $ options ['maxTimeMS ' ], 'integer ' );
163
188
}
164
189
190
+ if (isset ($ options ['min ' ]) && ! is_array ($ options ['min ' ]) && ! is_object ($ options ['min ' ])) {
191
+ throw InvalidArgumentException::invalidType ('"min" option ' , $ options ['min ' ], 'array or object ' );
192
+ }
193
+
165
194
if (isset ($ options ['modifiers ' ]) && ! is_array ($ options ['modifiers ' ]) && ! is_object ($ options ['modifiers ' ])) {
166
195
throw InvalidArgumentException::invalidType ('"modifiers" option ' , $ options ['modifiers ' ], 'array or object ' );
167
196
}
@@ -186,10 +215,22 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
186
215
throw InvalidArgumentException::invalidType ('"readPreference" option ' , $ options ['readPreference ' ], 'MongoDB\Driver\ReadPreference ' );
187
216
}
188
217
218
+ if (isset ($ options ['returnKey ' ]) && ! is_bool ($ options ['returnKey ' ])) {
219
+ throw InvalidArgumentException::invalidType ('"returnKey" option ' , $ options ['returnKey ' ], 'boolean ' );
220
+ }
221
+
222
+ if (isset ($ options ['showRecordId ' ]) && ! is_bool ($ options ['showRecordId ' ])) {
223
+ throw InvalidArgumentException::invalidType ('"showRecordId" option ' , $ options ['showRecordId ' ], 'boolean ' );
224
+ }
225
+
189
226
if (isset ($ options ['skip ' ]) && ! is_integer ($ options ['skip ' ])) {
190
227
throw InvalidArgumentException::invalidType ('"skip" option ' , $ options ['skip ' ], 'integer ' );
191
228
}
192
229
230
+ if (isset ($ options ['snapshot ' ]) && ! is_bool ($ options ['snapshot ' ])) {
231
+ throw InvalidArgumentException::invalidType ('"snapshot" option ' , $ options ['snapshot ' ], 'boolean ' );
232
+ }
233
+
193
234
if (isset ($ options ['sort ' ]) && ! is_array ($ options ['sort ' ]) && ! is_object ($ options ['sort ' ])) {
194
235
throw InvalidArgumentException::invalidType ('"sort" option ' , $ options ['sort ' ], 'array or object ' );
195
236
}
@@ -257,14 +298,16 @@ private function createQuery()
257
298
}
258
299
}
259
300
260
- foreach (['allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , 'projection ' , 'readConcern ' , 'skip ' , 'sort ' ] as $ option ) {
301
+ foreach (['allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxScan ' , ' maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , 'projection ' , 'readConcern ' , 'returnKey ' , ' showRecordId ' , ' skip ' , ' snapshot ' , 'sort ' ] as $ option ) {
261
302
if (isset ($ this ->options [$ option ])) {
262
303
$ options [$ option ] = $ this ->options [$ option ];
263
304
}
264
305
}
265
306
266
- if (isset ($ this ->options ['collation ' ])) {
267
- $ options ['collation ' ] = (object ) $ this ->options ['collation ' ];
307
+ foreach (['collation ' , 'max ' , 'min ' ] as $ option ) {
308
+ if (isset ($ this ->options [$ option ])) {
309
+ $ options [$ option ] = (object ) $ this ->options [$ option ];
310
+ }
268
311
}
269
312
270
313
$ modifiers = empty ($ this ->options ['modifiers ' ]) ? [] : (array ) $ this ->options ['modifiers ' ];
0 commit comments