MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home

Use this function for commands that both read and write, such as "mapReduce" with an output collection.

Read and write concern and collation can be overridden by various sources. In a transaction, read concern and write concern are prohibited in opts. The highest-priority sources for these options are listed first in the following table. Read preferences are not applied. The write concern is omitted for MongoDB before 3.4.

Read Concern
Write Concern
Collation

opts

opts

opts

Transaction

Transaction

database, collection, or client

database, collection, or client

See the example for transactions and for the "distinct" command with opts.