Use this function for commands that read such as "count" or "distinct".
Read preferences, read concern, and collation can be overridden by various sources. In a transaction, read concern
and write concern are prohibited in opts
and the read preference must be primary or NULL. The highest-priority
sources for these options are listed first in the following table. No write concern is applied.
Read Preferences | Read Concern | Collation |
---|---|---|
|
|
|
Transaction | Transaction | |
|
================== ============== =========
Read Preferences Read Concern Collation
================== ============== =========
read_prefs
opts
opts
Transaction Transaction
database,
client
, collection
================== ============== =========
See the example for transactions and for the "distinct" command with opts.