File tree 1 file changed +22
-1
lines changed
src/Jenssegers/Mongodb/Query
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ class Builder extends BaseBuilder {
28
28
* @var int
29
29
*/
30
30
public $ timeout ;
31
+
32
+ /**
33
+ * The cursor hint value.
34
+ *
35
+ * @var int
36
+ */
37
+ public $ hint ;
31
38
32
39
/**
33
40
* Indicate if we are executing a pagination query.
@@ -103,6 +110,19 @@ public function timeout($seconds)
103
110
104
111
return $ this ;
105
112
}
113
+
114
+ /**
115
+ * Set the cursor hint.
116
+ *
117
+ * @param mixed $index
118
+ * @return $this
119
+ */
120
+ public function hint ($ index )
121
+ {
122
+ $ this ->hint = $ index ;
123
+
124
+ return $ this ;
125
+ }
106
126
107
127
/**
108
128
* Execute a query for a single record by ID.
@@ -266,11 +286,12 @@ public function getFresh($columns = array())
266
286
// Execute query and get MongoCursor
267
287
$ cursor = $ this ->collection ->find ($ wheres , $ columns );
268
288
269
- // Apply order, offset and limit
289
+ // Apply order, offset, limit and hint
270
290
if ($ this ->timeout ) $ cursor ->timeout ($ this ->timeout );
271
291
if ($ this ->orders ) $ cursor ->sort ($ this ->orders );
272
292
if ($ this ->offset ) $ cursor ->skip ($ this ->offset );
273
293
if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
294
+ if ($ this ->hint ) $ cursor ->hint ($ this ->hint );
274
295
275
296
// Return results as an array with numeric keys
276
297
return iterator_to_array ($ cursor , false );
You can’t perform that action at this time.
0 commit comments