Created_by name added in the establishment list api
This commit is contained in:
parent
ce45de6a27
commit
4cc2b1c1d0
@ -325,7 +325,21 @@ exports.getAllEstablishments = async (req, res) => {
|
|||||||
attributes: {
|
attributes: {
|
||||||
include: [
|
include: [
|
||||||
[
|
[
|
||||||
Sequelize.literal(`(SELECT COUNT(*) FROM establishment_products ep WHERE ep.establishment_id = establishments.id)`),"product_count" ]
|
Sequelize.literal(`(
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM establishment_products ep
|
||||||
|
WHERE ep.establishment_id = establishments.id
|
||||||
|
)`),
|
||||||
|
"product_count"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Sequelize.literal(`(
|
||||||
|
SELECT name
|
||||||
|
FROM admin_users au
|
||||||
|
WHERE au.id = establishments.created_by
|
||||||
|
)`),
|
||||||
|
"created_by_name"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
@ -336,7 +350,7 @@ exports.getAllEstablishments = async (req, res) => {
|
|||||||
{ model: user, as: "created_user", attributes: ["name"] },
|
{ model: user, as: "created_user", attributes: ["name"] },
|
||||||
],
|
],
|
||||||
order: [[sort_by, sort_order]],
|
order: [[sort_by, sort_order]],
|
||||||
...(exportType ? {} : { limit, offset }), // pagination only when not exporting
|
...(exportType ? {} : { limit, offset }),
|
||||||
});
|
});
|
||||||
|
|
||||||
// If export = excel → generate file
|
// If export = excel → generate file
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user