Skip to content

Commit 7cd6e31

Browse files
p-mongop
andauthored
RUBY-1672 Document passing read concern to find operations in tutorial (#2046)
Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 650dbc9 commit 7cd6e31

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

source/tutorials/ruby-driver-crud-operations.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,40 @@ following code example shows how a tailable cursor might be used:
352352
sleep(1)
353353
end
354354

355+
356+
Read Concern
357+
------------
358+
359+
Read concern can be :ref:`set on the client <ruby-driver-client-options>`
360+
or on the collection:
361+
362+
.. code-block:: ruby
363+
364+
client = Mongo::Client.new(['localhost:14420'], database: 'music',
365+
read_concern: {level: :local})
366+
367+
client['collection'].find.to_a
368+
369+
collection = client['collection', read_concern: {level: :majority}]
370+
371+
collection.find.to_a
372+
373+
The driver does not currently support setting read concern on an individual
374+
query.
375+
376+
Read concern can be specified when :ref:`starting a transaction
377+
<using-transactions>`. When a transaction is active, :manual:`any read concern
378+
specified on the client or on the collection is ignored
379+
</core/transactions/#transactions-and-read-concern>`.
380+
381+
When using the generic command helper, the read concern can be specified as
382+
part of the command:
383+
384+
.. code-block:: ruby
385+
386+
client.database.command(collstats: 'test', readConcern: {level: :majority})
387+
388+
355389
.. _ruby-driver-read-preference:
356390

357391
Read Preference

source/tutorials/ruby-driver-transactions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Version 4.0 of the MongoDB server introduces
1616
(Updates to multiple fields within a single document are atomic in all
1717
versions of MongoDB.) Ruby driver version 2.6.0 adds support for transactions.
1818

19+
.. _using-transactions:
20+
1921
Using Transactions
2022
==================
2123

0 commit comments

Comments
 (0)