From 69b5e66d12ecb9caab6840dba4fa81546f7aa896 Mon Sep 17 00:00:00 2001 From: dagmawig Date: Sat, 29 Jan 2022 21:59:21 -0600 Subject: [PATCH] feat: add default order by created_at desc --- server/models/Tree.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/server/models/Tree.ts b/server/models/Tree.ts index 9e10d745..1c5f6c48 100644 --- a/server/models/Tree.ts +++ b/server/models/Tree.ts @@ -28,17 +28,19 @@ function getByFilter( */ function getFeaturedTree(treeRepository: TreeRepository) { return async function () { - // const trees = await treeRepository.getByFilter( - // { - // approved: true, - // }, {limit: 10}); - const trees: Array = []; - // eslint-disable-next-line no-restricted-syntax - for (const id of [186737, 186735, 186736, 186734]) { - // eslint-disable-next-line no-await-in-loop - const tree = await treeRepository.getById(id); - trees.push(tree); - } + const trees = await treeRepository.getByFilter( + { + approved: true, + }, + { limit: 10, orderBy: { column: 'created_at', direction: 'desc' } }, + ); + // const trees: Array = []; + // // eslint-disable-next-line no-restricted-syntax + // for (const id of [186737, 186735, 186736, 186734]) { + // // eslint-disable-next-line no-await-in-loop + // const tree = await treeRepository.getById(id); + // trees.push(tree); + // } return trees; }; }