Putting it all together
Now that we have gone over the core tenets of using transactions with Sequelize, we can begin adding to our Avalon Airlines project. Our business partner just informed us that the investors want a small demonstration for booking a flight without processing a payment. For this task, we will need to add a couple of new files, update the BoardingTicket
and FlightSchedule
models, add new routes to our express application, and install a new Node.js package.
First, let us begin by adding the new Node.js package that the project will require. This package is known as Luxon (https://moment.github.io/luxon/), which is a date-and-time JavaScript library. Use the following command to add the package:
npm i --save luxon
Next, we will want to modify a life cycle event that exists within the BoardingTicket
model located in models/boardingticket.js
by adding/changing the following highlighted code:
BoardingTicket.beforeSave('checkSeat', async (ticket...