Complete the code to set the write concern to acknowledge writes on the primary only.
db.collection.insertOne({name: 'Alice'}, {writeConcern: {w: [1])Setting w: 1 means the write is acknowledged by the primary only.
Complete the code to ensure the write is acknowledged by the majority of replica set members.
db.collection.insertOne({score: 100}, {writeConcern: {w: "[1]"}})Using w: 'majority' ensures the write is confirmed by most nodes, increasing durability.
Fix the error in the write concern option to wait for journaling confirmation.
db.collection.insertOne({item: 'book'}, {writeConcern: {w: 1, j: [1])Setting j: true waits for the write to be committed to the journal, ensuring durability.
Fill both blanks to set write concern to wait for 2 nodes and enable journaling.
db.collection.insertOne({status: 'active'}, {writeConcern: {w: [1], j: [2])j as a number instead of boolean.w as 'majority' when number 2 is required.Setting w: 2 waits for acknowledgment from 2 nodes, and j: true waits for journaling.
Fill all three blanks to set write concern with majority, journaling enabled, and a timeout of 5000 ms.
db.collection.insertOne({task: 'backup'}, {writeConcern: {w: "[1]", j: [2], wtimeout: [3])wtimeout as a boolean or string instead of a number.j to false disables journaling.Using w: 'majority' waits for most nodes, j: true enables journaling, and wtimeout: 5000 sets a 5-second timeout.