From cfc0ce0e5bd9cb889a7181827c9e9ad8fa752b3c Mon Sep 17 00:00:00 2001 From: Hagop Jamkojian Date: Sat, 3 Oct 2020 10:59:18 +0200 Subject: [PATCH] Add default sort order Closes #31 --- src/models/plugins/paginate.plugin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/models/plugins/paginate.plugin.js b/src/models/plugins/paginate.plugin.js index 20f58d35..392ccd50 100644 --- a/src/models/plugins/paginate.plugin.js +++ b/src/models/plugins/paginate.plugin.js @@ -27,6 +27,8 @@ const paginate = (schema) => { sortingCriteria.push((order === 'desc' ? '-' : '') + key); }); sort = sortingCriteria.join(' '); + } else { + sort = 'createdAt'; } const limit = options.limit && parseInt(options.limit, 10) > 0 ? parseInt(options.limit, 10) : 10;