Add 'get unique tags' query

This commit is contained in:
Sam Becker 2023-09-18 09:33:17 -05:00
parent 1e8c4c839f
commit 2d0fb2f9e3
2 changed files with 5 additions and 0 deletions

View File

@ -12,6 +12,7 @@
"sonner", "sonner",
"thephotoblog", "thephotoblog",
"trpc", "trpc",
"unnest",
"WRHGZC", "WRHGZC",
"zadd", "zadd",
"zrange" "zrange"

View File

@ -246,6 +246,10 @@ export const getPhotosCount = async () => sql`
SELECT COUNT(*) FROM photos SELECT COUNT(*) FROM photos
`.then(({ rows }) => parseInt(rows[0].count, 10)); `.then(({ rows }) => parseInt(rows[0].count, 10));
export const getUniqueTags = async () => sql`
SELECT DISTINCT unnest(tags) FROM photos
`.then(({ rows }) => rows.map(row => row.unnest as string));
export const getPhoto = async (id: string): Promise<Photo | undefined> => { export const getPhoto = async (id: string): Promise<Photo | undefined> => {
// Check for photo id forwarding // Check for photo id forwarding
// and convert short ids to uuids // and convert short ids to uuids