[[:oktatas:web:back-end_framework:express|< Express]]
====== Express - Visszaadott mezők szabályozása ======
* **Szerző:** Sallai András
* Copyright (c) 2025, Sallai András
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== Kontroller =====
const employees = await Employee.findAll({
attributes: ['id', 'name', 'city', 'salary']
})
===== Mezők szabályozása táblakapcsolással =====
const employees = await Employee.findAll({
attributes: ['id', 'name', 'city', 'salary'],
include: {
model: Rank,
attributes: ['name']
}
})
===== Create művelet =====
Egyik lehetőség:
const employee = await Employee.create(req.body)
delete employee.dataValues.createdAt
delete employee.dataValues.updatedAt
Másik lehetőség:
const employee = await Employee.create(req.body)
employee.toJSON = function () {
const values = { ...this.get() }
delete values.createdAt
delete values.updatedAt
return values
}