Skip to content

Commit 8809fb6

Browse files
p-mongop
andauthored
RUBY-2220 Move find command construction code into operations layer
(#2275) * RUBY-2220 Move find command construction code into operations layer * fix explain test on old sharded cluster servers * remove read preference * 2706 again Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent bee32ea commit 8809fb6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

source/reference/crud-operations.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,32 @@ when querying and their corresponding methods as examples.
260260
# MongoDB 2.6
261261
client[:artists].find.explain(verbose: true)
262262

263+
The explain operation supports ``:session`` and ``:read``
264+
(for read preference) options. To specify these options for a single
265+
explain operation, they must be given to the ``find`` method as
266+
follows:
267+
268+
.. code-block:: ruby
269+
270+
client[:artists].find({}, session: session).explain
271+
272+
client[:artists].find({}, read: {mode: :secondary_preferred}).explain
273+
274+
If the read preference option is specified on the client or on the
275+
collection, it will be passed to the explain operation:
276+
277+
.. code-block:: ruby
278+
279+
client[:artists, read: {mode: :secondary_preferred}].find.explain
280+
281+
Note that the session option is not accepted when creating a collection
282+
object.
283+
284+
The explain command does not support passing the read concern option.
285+
If the read concern is specifed on the client or collection level, or
286+
if the read concern is specified as a find option, it will NOT be passed
287+
by the driver to the explain command.
288+
263289
.. note::
264290

265291
The information returned by the server for the ``explain`` command

0 commit comments

Comments
 (0)