diff options
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 |
