diff options
Diffstat (limited to 'lib/db/index.js')
| -rw-r--r-- | lib/db/index.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/db/index.js b/lib/db/index.js index 8e72d34..2c8486b 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -74,8 +74,16 @@ db.getFileSizes = function(ids){ } /* COMMENTS */ -db.getCommentsForThread = function (id){ - return Comment.query("where", "thread", "=", id).fetchAll() +db.getCommentsForThread = function (id, limit, offset){ + return Comment.query(function(qb){ + qb.where("thread", "=", id).orderBy("id", "desc") + if (limit) { + qb = qb.limit(limit) + } + if (offset) { + qb = qb.offset(offset) + } + }).fetchAll() } db.getCommentCounts = function(ids){ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') |
