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 @@ -32,6 +32,13 @@ class Builder extends QueryBuilder {
32
32
* @var int
33
33
*/
34
34
public $ timeout ;
35
+
36
+ /**
37
+ * The cursor hint value.
38
+ *
39
+ * @var int
40
+ */
41
+ public $ hint ;
35
42
36
43
/**
37
44
* All of the available clause operators.
@@ -99,6 +106,19 @@ public function timeout($seconds)
99
106
100
107
return $ this ;
101
108
}
109
+
110
+ /**
111
+ * Set the cursor hint.
112
+ *
113
+ * @param mixed $index
114
+ * @return $this
115
+ */
116
+ public function hint ($ index )
117
+ {
118
+ $ this ->hint = $ index ;
119
+
120
+ return $ this ;
121
+ }
102
122
103
123
/**
104
124
* Execute a query for a single record by ID.
@@ -249,11 +269,12 @@ public function getFresh($columns = array())
249
269
// Execute query and get MongoCursor
250
270
$ cursor = $ this ->collection ->find ($ wheres , $ columns );
251
271
252
- // Apply order, offset and limit
272
+ // Apply order, offset, limit and hint
253
273
if ($ this ->timeout ) $ cursor ->timeout ($ this ->timeout );
254
274
if ($ this ->orders ) $ cursor ->sort ($ this ->orders );
255
275
if ($ this ->offset ) $ cursor ->skip ($ this ->offset );
256
276
if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
277
+ if ($ this ->hint ) $ cursor ->hint ($ this ->hint );
257
278
258
279
// Return results as an array with numeric keys
259
280
return iterator_to_array ($ cursor , false );
You can’t perform that action at this time.
0 commit comments