Skip to content

Commit

Permalink
feat: add ordering query param to audit table
Browse files Browse the repository at this point in the history
  • Loading branch information
frantzarty committed Apr 7, 2022
1 parent d2a0ae9 commit 1d7c429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/controllers/audit.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ import {

export const findAll = async (req, res) => {
try {
let { page, limit, orgUid } = req.query;
let { page, limit, orgUid, order } = req.query;

let pagination = paginationParams(page, limit);

const auditResults = await Audit.findAndCountAll({
where: { orgUid },
order: [['onchainConfirmationTimeStamp', order || 'DESC']],
...pagination,
});

console.log(auditResults);

return res.json(optionallyPaginatedResponse(auditResults, page, limit));
} catch (error) {
res.status(400).json({
message: 'Can not retreive issuances',
message: 'Can not retreive audit data',
error: error.message,
});
}
Expand Down
1 change: 1 addition & 0 deletions src/validations/audit.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const auditGetSchema = Joi.object()
page: Joi.number(),
limit: Joi.number(),
orgUid: Joi.string(),
order: Joi.string().valid('ASC', 'DESC').optional(),
})
.with('page', 'limit')
.with('limit', 'page');

0 comments on commit 1d7c429

Please sign in to comment.