Complete the code to set the read concern level to 'majority' for stronger consistency.
db.collection.find().readConcern('[1]')
Setting readConcern to 'majority' ensures the query reads data acknowledged by a majority of nodes, improving consistency.
Complete the code to set the write concern to acknowledge writes by 3 nodes.
db.collection.insertOne(doc, { writeConcern: { w: [1] } })Setting writeConcern w to 3 means the write must be acknowledged by 3 nodes, increasing durability but possibly reducing performance.
Fix the error in the code to set read preference to nearest for better performance.
db.collection.find().readPreference('[1]')
Using 'nearest' read preference allows reading from the closest node, improving read performance but possibly reducing consistency.
Fill both blanks to set a transaction with read concern 'snapshot' and write concern 'majority'.
session.startTransaction({ readConcern: { level: '[1]' }, writeConcern: { w: '[2]' } })Transactions use 'snapshot' read concern for consistent reads and 'majority' write concern for durability.
Fill both blanks to create a read operation with read preference 'secondary', read concern 'local'.
db.collection.find().readPreference('[1]').readConcern('[2]')
This configuration reads from secondary nodes with local consistency.