I am building my backend in node using Sequelize and I have created methods to return the values of a log. The majority of these values are connected to other tables and have numbers stored corresponding to the foreign keys in the linked tables.
Are there any easy way to pull the values the numbers relate to using Sequelize? What is the most common method to use?
When I display them on the front-end the numbers obviously won’t mean anything by themselves.
const db = require("../server/models");
const diveLog = db.diveLog;
const User = db.userLogin;
exports.allDiveLogs = (req, res) => {
diveLog.findAll({
})
.then((diveLog) => {
if (!diveLog) {
return res.status(404).send({ message: "No dive logs stored" });
}
console.log(diveLog)
res.status(200).send({
diveTypeID: diveLog.dataValues.diveTypeID,
diveSchoolNameID: diveLog.dataValues.diveSchoolNameID,
diveCurrentID: diveLog.dataValues.diveCurrentID,
diveVisibilityID: diveLog.dataValues.diveVisibilityID,
diveDate: diveLog.dataValues.diveDate,
diveMaxDepth: diveLog.dataValues.diveMaxDepth,
diverUserNumber: diveLog.dataValues.diverUserNumber,
diveVerifiedBySchool: diveLog.dataValues.diveVerifiedBySchool,
diveNotes: diveLog.dataValues.diveNotes,
});
})
.catch((err) => {
res.status(500).send({ message: err.message });
});
};