diff options
| author | Spawn <spawn@spawn.local> | 2017-08-09 13:49:44 +0200 |
|---|---|---|
| committer | Spawn <spawn@spawn.local> | 2017-08-09 13:49:44 +0200 |
| commit | c717d5d9ee5dd07588b426c0d4c87a12b7dabf3b (patch) | |
| tree | fa9fd312d191388b22d6fc07c5baa3108324c8ec | |
| parent | 4088519b98f346de4dbe36352afa05c74e6583a6 (diff) | |
fix orderby
| -rw-r--r-- | lib/db/crud.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/db/crud.js b/lib/db/crud.js index 0ee438d..3aa0127 100644 --- a/lib/db/crud.js +++ b/lib/db/crud.js @@ -11,13 +11,13 @@ module.exports = function(model) { if (q.offset) { delete q.offset } + delete q.orderBy if (Object.keys(q).length > 0) qb.where(q) if (orderBy) { const ob = orderBy.split(" ") const ob_field = ob[0] || 'id' const ob_dir = ob[1] || 'desc' qb.orderBy(ob_field, ob_dir) - delete q.orderBy } if (limit) qb.limit( limit ) if (offset) qb.offset( offset ) @@ -44,4 +44,4 @@ module.exports = function(model) { return new model({'id': id}).destroy() }, } -}
\ No newline at end of file +} |
