From 0d0c04ad510264f2dbd2deb3bbf0b0d0c0605a62 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 4 Sep 2015 23:37:33 -0400 Subject: get hootbox --- lib/db/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/db') 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') -- cgit v1.2.3-70-g09d2