From the course: Databases for Node.js Developers

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Creating the order and using transactions

Creating the order and using transactions - Node.js Tutorial

From the course: Databases for Node.js Developers

Creating the order and using transactions

- [Instructor] So far, we built a functional basket system, using Redis, and integrated product details from MongoDB. Now we are taking it to the next step, turning the basket into an order. This is where we bring in MySQL and ensure everything works together smoothly. To do this, we will fetch all basket items from Redis. We will retrieve product details from MongoDB and we will then create an order in MySQL, using a transaction. The transaction ensures that the order is complete and consistent, and if anything goes wrong, we can roll it back to prevent partial orders. So let's get started. I'm now back in Virtual Studio Code and there, I'm opening routes basket.js because this is where everything, what we're going to do now will be happening. I take this item fetching code and copy it because we will use something very similar for the buyer route now. So I copy everything here from my line 26, down to 39. I copy it and then I scroll down until I find the post by route, and it's…

Contents