diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-04 23:37:33 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-04 23:37:33 -0400 |
| commit | 0d0c04ad510264f2dbd2deb3bbf0b0d0c0605a62 (patch) | |
| tree | cde48b2e1db249f61edafc28fd649aed22583fd4 /lib/db | |
| parent | b2d2bc1c592f5263ed30c26b6a8ea5f48e230e90 (diff) | |
get hootbox
Diffstat (limited to 'lib/db')
| -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') |
