summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-09-07 02:17:51 -0400
committerJules Laplace <jules@okfoc.us>2015-09-07 02:17:51 -0400
commit694dbdf6ff3eef3e33fcbe95ebd676eea3353dcc (patch)
tree91b2cf8a9310005e9bd6d1ff443ef7d593086271 /lib
parentf5cd692caf98cfeddc61df6442d401619d264aa7 (diff)
linking urls
Diffstat (limited to 'lib')
-rw-r--r--lib/bucky.js2
-rw-r--r--lib/db/index.js9
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/bucky.js b/lib/bucky.js
index ad2018f..a429fb3 100644
--- a/lib/bucky.js
+++ b/lib/bucky.js
@@ -54,7 +54,7 @@ var bucky = module.exports = {
})
},
ensureHootbox: function (req, res, next){
- db.getCommentsForThread(1, 9).then(function(hootbox){
+ db.getCommentsForThread(1, 9, 0, "desc").then(function(hootbox){
res.hootbox = hootbox
next()
})
diff --git a/lib/db/index.js b/lib/db/index.js
index 7452f3d..1ebae57 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -88,14 +88,15 @@ db.getFileSizes = function(ids){
/* COMMENTS */
-db.getCommentsForThread = function (id, limit, offset){
+db.getCommentsForThread = function (id, limit, offset, order){
+ order = order || "asc"
return Comment.query(function(qb){
- qb.where("thread", "=", id).orderBy("id", "asc")
+ qb.where("thread", "=", id).orderBy("id", order)
if (limit) {
- qb = qb.limit(limit)
+ qb.limit(limit)
}
if (offset) {
- qb = qb.offset(offset)
+ qb.offset(offset)
}
}).fetchAll().then(function(comments){
comments.forEach(function(comment){