summaryrefslogtreecommitdiff
path: root/bucky/db/index.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2022-10-26 18:52:52 +0200
committerjulian laplace <julescarbon@gmail.com>2022-10-26 18:52:52 +0200
commitb05925febcabb4caa5e1f5d4503f7ddd23708b26 (patch)
tree55274c185498e7f123f695bac3181b642cb6a96b /bucky/db/index.js
parentefd2c35d432dc2426bf1fd9c849eeabdf28e40e3 (diff)
upgrade knex and bookshelf and fix thread/keyword apis
Diffstat (limited to 'bucky/db/index.js')
-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 */