How to do transaction/locking in mongodb?



How to do transaction/locking in mongodb?..

Answer / Anju Upadhyay

MongoDB supports multi-document transactions starting from MongoDB 4.0, but it does not support row-level locking as seen in traditional relational databases.nTo perform a multi-document transaction, you can use the beginTransaction and commitTransaction methods within a session. The isolation level is set to snapshot isolation by default, which ensures that transactions see a consistent snapshot of data during their execution.nFor better concurrency control, you can also implement optimistic locking using versioning or timestamp fields in your documents.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MongoDB Interview Questions

What do you mean by a replica set in mongodb?

1 Answers  


Why is mongodb so popular?

1 Answers  


Does an update fsync to disk immediately?

1 Answers  


How to convert string to objectid in mongoose?

1 Answers  


How to insert data into mongodb using mongoose?

1 Answers  


Is mongodb compass free?

1 Answers  


Explain what is mongodb?

1 Answers  


Where are mongodb databases stored?

1 Answers  


List some alternatives to mongodb?

1 Answers  


What is difference between hadoop and mongodb?

1 Answers  


How much ram do I need for mongodb?

1 Answers  


Mention what is the basic syntax to use index in mongodb?

1 Answers  


Categories