()
| 456 | } |
| 457 | |
| 458 | export async function getCategories() { |
| 459 | try { |
| 460 | const categories = await db.categories.findMany({ |
| 461 | select: { |
| 462 | id: true, |
| 463 | category: true, |
| 464 | }, |
| 465 | distinct: ["category"], |
| 466 | }); |
| 467 | return categories; |
| 468 | } catch (e) { |
| 469 | return []; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | export async function addCategory(category: string) { |
| 474 | const newCategory = await db.categories.create({ |