0
0
MongoDBquery~10 mins

Read concern levels (local, majority, snapshot) in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the read concern level to local in a MongoDB query.

MongoDB
db.collection.find().readConcern('[1]')
Drag options to blanks, or click blank then click option'
Alinearizable
Blocal
Csnapshot
Dmajority
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'majority' when you want the fastest local read.
Confusing 'snapshot' with 'local' read concern.
2fill in blank
medium

Complete the code to set the read concern level to majority in a MongoDB query.

MongoDB
db.collection.find().readConcern('[1]')
Drag options to blanks, or click blank then click option'
Amajority
Blocal
Csnapshot
Davailable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' when you want guaranteed majority confirmation.
Using 'snapshot' which is different from majority.
3fill in blank
hard

Fix the error in the code to use the snapshot read concern correctly.

MongoDB
db.collection.find().readConcern('[1]')
Drag options to blanks, or click blank then click option'
Alocal
Bmajority
Csnapshot
Dlinearizable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'majority' instead of 'snapshot' for transactions.
Using 'local' which does not guarantee snapshot isolation.
4fill in blank
hard

Fill both blanks to set the read concern to majority and specify the read preference to primary.

MongoDB
db.collection.find().readConcern('[1]').readPreference('[2]')
Drag options to blanks, or click blank then click option'
Amajority
Blocal
Cprimary
Dsecondary
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing read preference with read concern values.
Using secondary read preference with majority read concern incorrectly.
5fill in blank
hard

Fill all three blanks to set a snapshot read concern, read from primary, and limit results to 5 documents.

MongoDB
db.collection.find().readConcern('[1]').readPreference('[2]').limit([3])
Drag options to blanks, or click blank then click option'
Alocal
Bprimary
C5
Dsnapshot
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' instead of 'snapshot' for consistent reads.
Forgetting to limit the number of documents.