Added order

This commit is contained in:
Torsten Schulz
2024-07-10 17:48:40 +02:00
parent 7ab3be1465
commit d4811660fe
9 changed files with 15 additions and 12 deletions

View File

@@ -10,7 +10,8 @@ const getAllContactPersons = async (req, res) => {
as: 'positions',
through: { attributes: [] }
}
]
],
order: ['name']
});
res.json(contactPersons);
} catch (error) {
@@ -74,13 +75,10 @@ const deleteContactPerson = async (req, res) => {
const filterContactPersons = async (req, res) => {
try {
const { config: configString } = req.body;
console.log(configString, typeof configString);
const config = JSON.parse(configString);
const where = {};
const having = [];
console.log(config, typeof config);
console.log(config.selection);
if (config.selection.id && config.selection.id === 'all') {
// No additional filter needed for "all"
} else if (config.selection.id) {
@@ -116,6 +114,7 @@ const filterContactPersons = async (req, res) => {
},
],
having: having.length > 0 ? { [Op.and]: having } : undefined,
order: ['name']
});
res.json(contactPersons);