diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
| commit | 1cfed2612fd1042a15d470a44ec87588c966dc12 (patch) | |
| tree | ba850f589194a21fd1587dd71dfcd056a242e4ac /bucky/db | |
| parent | ae311b71cccf5df9e0e19e276615cc32426d9de1 (diff) | |
hootstream... dark mode only
Diffstat (limited to 'bucky/db')
| -rw-r--r-- | bucky/db/index.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js index 8ab29ff..36541f8 100644 --- a/bucky/db/index.js +++ b/bucky/db/index.js @@ -114,6 +114,38 @@ db.getLastlog = function (limit) { .limit(limit || 10); }; +/** HOOTSTREAM */ + +db.getHootstreamFiles = ({ limit, offset }) => + knex("files") + .join("threads", "threads.id", "=", "files.thread") + .select("files.*") + .where("threads.privacy", false) + .orderBy("files.id", "desc") + .offset(offset) + .limit(limit); +db.getHootstreamComments = ({ limit, offset }) => + knex("comments") + .join("threads", "threads.id", "=", "comments.thread") + .select("comments.*") + .where("threads.privacy", false) + .orderBy("comments.id", "desc") + .offset(offset) + .limit(limit); +db.getHootstreamThreads = ({ files, comments }) => + Thread.where((builder) => + builder.whereIn( + "id", + Array.from( + new Set( + [...comments, ...files] + .map((item) => item?.thread) + .filter((item) => !!item) + ) + ) + ) + ).fetchAll(); + /* THREADS */ db.getLatestThreads = function () { @@ -149,6 +181,7 @@ db.getThreadsById = function (ids) { return Thread.where("id", "in", ids).fetchAll(); }; db.createThread = function (data) { + console.log(data); return new db.Thread(data).save(); }; db.updateThread = function (data) {}; |
