This chapter covers
- Understanding the WiredTiger Storage Engine
- Examining the ACID principles
- Comparing the Core and Callback APIs
- Implementing transactions with the Node.js driver
- Performing transactions using the Python driver
- Managing transactions with the Ruby driver
Transactions are discrete units of operation within a database management system, comprising multiple related read and write actions. These operations are grouped together and must all succeed as a whole or fail together, ensuring that no partial updates are left in the database. Consider a transaction for booking a travel package that includes a flight and a hotel. If the booking process successfully reserves a flight but encounters a problem with the hotel reservation, the entire transaction must be aborted. This means the flight reservation would also be undone, maintaining the status quo in the database.
Although MongoDB is a nonrelational database and traditionally does not follow the relational model’s approach to transactions, it has long ensured data integrity through its single-document operations. With the introduction of multidocument atomicity, consistency, isolation, and durability (ACID) transactions, however, MongoDB has significantly broadened its applicability and enhanced its capability to handle complex transaction scenarios.