Manipulating and querying data using Sequelize
After initializing our database’s structure and data, we should be able to view, modify, and remove the airplanes from our dashboard. For now, we will create very naive and simple implementations for our administrative tasks, but since we are the only technical employee at Avalon Airlines, this will not be a problem. As we continue creating the project, we will modify our application to become more robust and function with safety measures in mind.
Reading data
Replace the app.get('/', …)
block with the following code (in index.js
):
app.get('/', async function (req, res) { const airplanes = await models.Airplane.findAll(); res.send("<pre>" + JSON.stringify(airplanes, undefined, 4) + "</pre>"); });
After that, save the file and run...