0
0
MongoDBquery~10 mins

Write concern basics 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 write concern to acknowledge writes on the primary only.

MongoDB
db.collection.insertOne({name: "Alice"}, {writeConcern: {w: [1])
Drag options to blanks, or click blank then click option'
A0
Bmajority
C1
Dall
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'majority' when only primary acknowledgment is needed.
Using 0 which means no acknowledgment.
2fill in blank
medium

Complete the code to set the write concern to require acknowledgment from the majority of replica set members.

MongoDB
db.collection.insertOne({name: "Bob"}, {writeConcern: {w: [1])
Drag options to blanks, or click blank then click option'
Aall
B1
C0
Dmajority
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of 'majority' for stronger write guarantees.
Using 0 which means no acknowledgment.
3fill in blank
hard

Fix the error in the write concern option to wait for acknowledgment from two nodes.

MongoDB
db.collection.insertOne({name: "Carol"}, {writeConcern: {w: [1])
Drag options to blanks, or click blank then click option'
Amajority
B2
C"two"
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string like 'two' instead of the number 2.
Using 'majority' when a specific number is required.
4fill in blank
hard

Fill both blanks to set write concern to wait for majority acknowledgment and a timeout of 5000 milliseconds.

MongoDB
db.collection.insertOne({name: "Dave"}, {writeConcern: {w: [1], wtimeout: [2])
Drag options to blanks, or click blank then click option'
Amajority
B5000
C1000
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a timeout value too low or too high.
Using numeric w instead of 'majority' for majority acknowledgment.
5fill in blank
hard

Fill all three blanks to set write concern to wait for 3 nodes, enable journaling, and set a timeout of 2000 milliseconds.

MongoDB
db.collection.insertOne({name: "Eve"}, {writeConcern: {w: [1], j: [2], wtimeout: [3])
Drag options to blanks, or click blank then click option'
Atrue
B2000
C3
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'true' instead of boolean true.
Setting wtimeout too high or too low.