Add 'get unique tags' query
This commit is contained in:
parent
1e8c4c839f
commit
2d0fb2f9e3
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -12,6 +12,7 @@
|
||||
"sonner",
|
||||
"thephotoblog",
|
||||
"trpc",
|
||||
"unnest",
|
||||
"WRHGZC",
|
||||
"zadd",
|
||||
"zrange"
|
||||
|
||||
@ -246,6 +246,10 @@ export const getPhotosCount = async () => sql`
|
||||
SELECT COUNT(*) FROM photos
|
||||
`.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> => {
|
||||
// Check for photo id forwarding
|
||||
// and convert short ids to uuids
|
||||
|
||||
Loading…
Reference in New Issue
Block a user