summaryrefslogtreecommitdiff
path: root/bucky/db
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/db')
-rw-r--r--bucky/db/index.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js
index 2e6deab..57b9c1c 100644
--- a/bucky/db/index.js
+++ b/bucky/db/index.js
@@ -167,6 +167,31 @@ db.getHootstreamThreads = ({ files, comments }) =>
)
)
).fetchAll();
+db.getHootstreamAllCommentsForThread = (thread) =>
+ Comment.where((builder) => builder.where("thread", thread.id)).fetchAll();
+db.getHootstreamAllFilesForThread = (thread) =>
+ File.where((builder) => builder.where("thread", thread.id)).fetchAll();
+
+db.getHootstreamSomeFilesForThreads = (threads, count = 1) =>
+ Promise.all(
+ threads.map((thread) =>
+ File.query((builder) =>
+ builder.where("thread", thread.id).orderBy("date", "desc").limit(count)
+ ).fetchAll()
+ )
+ ).then((results) =>
+ results.reduce((list, result) => list.concat(Array.from(result)), [])
+ );
+db.getHootstreamSomeCommentsForThreads = (threads, count = 1) =>
+ Promise.all(
+ threads.map((thread) =>
+ Comment.query((builder) =>
+ builder.where("thread", thread.id).orderBy("date", "desc").limit(count)
+ ).fetchAll()
+ )
+ ).then((results) =>
+ results.reduce((list, result) => list.concat(Array.from(result)), [])
+ );
/* THREADS */