The primary goal of a transaction is to let you update multiple documents in MongoDB in isolation, and potentially undo all the updates if some error occurs by aborting the transaction.
Mongoose 5.10.0 was released on August 14, 2020. Mongoose 5.10 is a semver minor version that introduces several important new features. In this article, I'll describe what is arguably the most important new feature: the [Connection#transaction()](https://mongoosejs.com/docs/api/connection.html#connection_Connection-transaction)
function, which improves Mongoose's support for MongoDB transactions.
The primary goal of a transaction is to let you update multiple documents in MongoDB in isolation, and potentially undo all the updates if some error occurs by aborting the transaction. For example, if you start a transaction and insert two documents, calling abortTransaction()
makes it so neither of the documents end up in the database:
const session = await Customer.startSession();
session.startTransaction();
// Passing the `session` option is how you indicate that `create()` is part of a transaction
await Customer.create([{ name: 'Test' }], { session: session });
await Customer.create([{ name: 'Test2' }], { session: session });
await session.abortTransaction();
const count = await Customer.countDocuments();
count; // 0, no documents were inserted, because the transaction was aborted.
Sessions have a convenient withTransaction()
function that handles aborting the transaction if an error occurs. For example, the below code shows that the withTransaction()
function successfully undoes any changes when the transaction executor function throws an error.
Visual Analytics and Advanced Data Visualization - How CanvasJS help enterprises in creating custom Interactive and Analytical Dashboards for advanced visual analytics for data visualization
Visualization Best Practices for Data Scientists. Disclaimer: The ideas presented in this article are from the book: Story Telling With Data by Cole Nussbaumer Knaflic.
The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.
The Importance of Data Visualization - It is the process of converting raw data at hand into easy and understandable image-photo-graphics for fast, effective and accurate…
Data Quality Testing Skills Needed For Data Integration Projects. Data integration projects fail for many reasons. Risks can be mitigated when well-trained testers deliver support. Here are some recommended testing skills.