InterviewHubPRO
Section Overview
Q34

Question 34 of 60

Part 3: NoSQL & Document Databases (MongoDB, DynamoDB) (26 - 40)

57%
Databases & System Design•Part 3: NoSQL & Document Databases (MongoDB, DynamoDB) (26 - 40)

Write Concerns & Read Concerns:

In Simple Words:

  • Write Concern (w: "majority"): Waits for a majority of replica nodes to commit before acknowledging.
  • Read Concern ("majority"): Reads only data committed by a majority of nodes to avoid dirty reads.
javascript
await db.collection('payments').insertOne(
  { transactionId: "txn_789", amount: 1000 },
  { writeConcern: { w: "majority", wtimeout: 5000 } }
);