diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-04 23:24:31 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-04 23:24:31 -0400 |
| commit | b2d2bc1c592f5263ed30c26b6a8ea5f48e230e90 (patch) | |
| tree | dcaf5ddec25e2877694051610b46af9bfac409b8 /lib/db/index.js | |
| parent | c609f54f161901098cdcd3739b3591e486ceb238 (diff) | |
db calls
Diffstat (limited to 'lib/db/index.js')
| -rw-r--r-- | lib/db/index.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/db/index.js b/lib/db/index.js index 3761417..8e72d34 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -67,13 +67,16 @@ db.getFilesForThread = function (id){ return File.query("where", "thread", "=", id).fetchAll() } db.getFileCounts = function(ids){ - return knex.column('thread', 'count(*)').select().from('comments').where('thread', 'in', ids).groupBy('thread') + return knex.column('thread').count('* as count').select().from('files').where('thread', 'in', ids).groupBy('thread') +} +db.getFileSizes = function(ids){ + return knex.column('thread').sum('size as size').select().from('files').where('thread', 'in', ids).groupBy('thread') } /* COMMENTS */ db.getCommentsForThread = function (id){ return Comment.query("where", "thread", "=", id).fetchAll() } -db.getCommentCounts = function(){ - return knex.column('thread', 'count(*)').select().from('files').where('thread', 'in', ids).groupBy('thread') +db.getCommentCounts = function(ids){ + return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') } |
