()
| 6 | export type Category = typeof categories.$inferSelect; |
| 7 | |
| 8 | export async function getAllBookmarks(): Promise<(Bookmark & { category: Category | null })[]> { |
| 9 | const results = await db |
| 10 | .select() |
| 11 | .from(bookmarks) |
| 12 | .leftJoin(categories, eq(bookmarks.categoryId, categories.id)); |
| 13 | |
| 14 | return results.map(row => ({ |
| 15 | ...row.bookmarks, |
| 16 | category: row.categories, |
| 17 | })); |
| 18 | } |
| 19 | |
| 20 | export async function getAllCategories(): Promise<Category[]> { |
| 21 | return await db.select().from(categories); |