| 30 | } |
| 31 | |
| 32 | static async getByName(userId: string, month: string, name: string) { |
| 33 | const budget = (await db.query<Budget>( |
| 34 | sql`SELECT * FROM "bewcloud_budgets" WHERE "user_id" = $1 AND "month" = $2 AND LOWER("name") = LOWER($3)`, |
| 35 | [ |
| 36 | userId, |
| 37 | month, |
| 38 | name, |
| 39 | ], |
| 40 | ))[0]; |
| 41 | |
| 42 | if (!budget) { |
| 43 | return null; |
| 44 | } |
| 45 | |
| 46 | // Numeric values come as strings, so we need to convert them to numbers |
| 47 | return { |
| 48 | ...budget, |
| 49 | value: Number(budget.value), |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | static async getById(userId: string, id: string) { |
| 54 | const budget = (await db.query<Budget>( |