From the course: Databases for Node.js Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Implement an order service

Implement an order service

From the course: Databases for Node.js Developers

Start my 1-month free trial

Implement an order service

- [Instructor] We will now implement the service responsible for the order management in MySQL. For that open server, services, OrderService and there we already started implementing this class, but our order management, we will use transactions. Transactions are a feature of the most relational databases and they in a nutshell, make sure that either all commands on the database are executed or none. This means, if you create one record in one table and few other records in another table and something goes wrong along the way, no record will be created. So it's either everything or nothing if those instructions are performed in a transaction. To later being able to run, work in a transaction, I will now create a new function async in transaction. And this function, just expects one argument, this is work. And work as you will see later is actually a function. Now I will first start the transaction. So I add const t equals…

Contents