diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:15:48 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:15:48 +0100 |
| commit | f8055775f3ac74e9e6054aef102673cefcf27986 (patch) | |
| tree | 6c7c302746db594ff0d61863f533633c7259de33 /bucky/db | |
| parent | 3975b8e7e2841298da1ad497ffe29ba004b55ec2 (diff) | |
more on profile
Diffstat (limited to 'bucky/db')
| -rw-r--r-- | bucky/db/index.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js index 935219f..a147cd8 100644 --- a/bucky/db/index.js +++ b/bucky/db/index.js @@ -93,6 +93,16 @@ db.getThreadsForKeyword = function (keyword) { qb.where("keyword", "=", keyword).orderBy("id", "desc") }).fetchAll() } +db.getThreadsForUser = function (username, limit, offset) { + return Thread.query(function(qb){ + qb.where("username", "=", username).orderBy("id", "desc").limit(limit || 40).offset(offset || 0) + }).fetchAll() +} +db.getTopThreadsForUser = function (username, limit, offset) { + return Thread.query(function(qb){ + qb.where("username", "=", username).orderBy("viewed", "desc").limit(limit || 40).offset(offset || 0) + }).fetchAll() +} db.getThread = function (id) { return Thread.query("where", "id", "=", id).fetch() } @@ -138,6 +148,14 @@ db.getFileById = function(id){ db.getFilesForThread = function (id){ return File.query("where", "thread", "=", id).fetchAll() } +db.getFilesForUser = function (username, limit, offset){ + return File.query(function(qb){ + qb.where("username", "=", username) + .orderBy('id', 'desc') + .limit(parseInt(limit) || 20) + .offset(parseInt(offset) || 0) + }).fetchAll() +} db.getFileCounts = function(ids){ return knex.column('thread').count('* as count').select().from('files').where('thread', 'in', ids).groupBy('thread') } @@ -225,6 +243,13 @@ db.getCommentById = function(id){ db.getCommentsById = function(ids){ return Comment.where("id", "in", ids).fetchAll() } +db.getCommentsForUser = function (username, limit){ + return Comment.query(function(qb){ + qb.where("username", "=", username) + .orderBy('date', 'desc') + .limit(parseInt(limit) || 20) + }).fetchAll() +} db.getCommentCounts = function(ids){ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread') } |
