format list
unknown
javascript
3 years ago
1.3 kB
3
Indexable
async function queryFormatList(db: ClientBase, tenantUuid: string): Promise<any>{ try { const data = await db.query( SELECT format.format_id, format.format_name, format.format_description, location.location_id, location.location_name, CAST(COUNT(format) OVER() AS INT) AS total FROM format JOIN location ON location.location_id = format.location_id WHERE format.deleted_at IS NULL AND location.deleted_at IS NULL AND format.tenant_uuid = $1 AND location.tenant_uuid = $1 GROUP BY format.format_id, format.format_name, format.format_description, location.location_id, location.location_name , [ tenant_uuid, ]) if(data.rowCount === 0 ) { return null; } return data.rows; } catch(e) { throw Error(e) } } export default async function formatList(req:Request, res:Response){ const db:ClientBase = req.namespace.db const {tenant_uuid} = getAuth(req) const formats = await queryFormatList(db, tenant_uuid); if (!formats) { throw Error(code.data_not_found) } success(res, { status: true, version: req.version, message: 'Success', data: formats , meta: null }) }catch (e) { failure(res, e) }
Editor is loading...