diff options
| author | Brandon Wong <29965003+brandonw3612@users.noreply.github.com> | 2025-04-13 22:50:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-13 21:50:45 +0100 |
| commit | 95f504c0bc0b9ec0930b6c6facefc1a8ea093192 (patch) | |
| tree | 967221d7f4f5b716cc8fd3d92b5869bacf1d6089 /packages/trpc/lib | |
| parent | 5bdb2d944a08f63772497e203f47533ffb640d82 (diff) | |
| download | karakeep-95f504c0bc0b9ec0930b6c6facefc1a8ea093192.tar.zst | |
feat: add support for filtering by bookmark age (#1228)
Diffstat (limited to 'packages/trpc/lib')
| -rw-r--r-- | packages/trpc/lib/search.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/trpc/lib/search.ts b/packages/trpc/lib/search.ts index ec582ef9..d4130798 100644 --- a/packages/trpc/lib/search.ts +++ b/packages/trpc/lib/search.ts @@ -25,6 +25,7 @@ import { tagsOnBookmarks, } from "@karakeep/db/schema"; import { Matcher } from "@karakeep/shared/types/search"; +import { toAbsoluteDate } from "@karakeep/shared/utils/relativeDateUtils"; import { AuthedContext } from ".."; @@ -279,6 +280,18 @@ async function getIds( ), ); } + case "age": { + const comp = matcher.relativeDate.direction === "newer" ? gte : lt; + return db + .select({ id: bookmarks.id }) + .from(bookmarks) + .where( + and( + eq(bookmarks.userId, userId), + comp(bookmarks.createdAt, toAbsoluteDate(matcher.relativeDate)), + ), + ); + } case "type": { const comp = matcher.inverse ? ne : eq; return db |
