Articles → MONGODB → Write Concern In MongoDB

Write Concern In MongoDB






Purpose





Syntax


db.[Table_name].insertOne(
{
   [inserted_document]
}, 
   {
      writeConcern:
      {
         w:[value], 
         j=[true/false], 
        wtimeout=[timeout value]
     }
})




  1. w → request acknowledgment that the write operation has propagated to a specified number of MongoDB instances
  2. j → request acknowledgment that the write operation has been written to the on-disk journal
  3. wtimeout → specify a time limit to prevent write operations from blocking indefinitely

Example


Picture showing
Click to Enlarge

Picture showing
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 22, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250