summaryrefslogtreecommitdiff
path: root/bucky/db/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/db/index.js')
-rw-r--r--bucky/db/index.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js
index 36541f8..2a1a3bf 100644
--- a/bucky/db/index.js
+++ b/bucky/db/index.js
@@ -116,19 +116,41 @@ db.getLastlog = function (limit) {
/** HOOTSTREAM */
-db.getHootstreamFiles = ({ limit, offset }) =>
+db.getHootstreamFiles = ({ limit, offset, thread, keyword, username }) =>
knex("files")
.join("threads", "threads.id", "=", "files.thread")
.select("files.*")
- .where("threads.privacy", false)
+ .where((builder) => {
+ builder.where("threads.privacy", false);
+ if (keyword) {
+ builder.where("threads.keyword", keyword);
+ }
+ if (thread) {
+ builder.where("threads.id", thread);
+ }
+ if (username) {
+ builder.where("comments.username", username);
+ }
+ })
.orderBy("files.id", "desc")
.offset(offset)
.limit(limit);
-db.getHootstreamComments = ({ limit, offset }) =>
+db.getHootstreamComments = ({ limit, offset, thread, keyword, username }) =>
knex("comments")
.join("threads", "threads.id", "=", "comments.thread")
.select("comments.*")
- .where("threads.privacy", false)
+ .where((builder) => {
+ builder.where("threads.privacy", false);
+ if (keyword) {
+ builder.where("threads.keyword", keyword);
+ }
+ if (thread) {
+ builder.where("threads.id", thread);
+ }
+ if (username) {
+ builder.where("comments.username", username);
+ }
+ })
.orderBy("comments.id", "desc")
.offset(offset)
.limit(limit);