Open source personal finance application
fix: add categories index and type rates validators
Ilya Komichevd6f31cad322d
diff --git a/convex/categories.ts b/convex/categories.tsindex 4e2ecea4..942ea3f6 100644--- a/convex/categories.ts+++ b/convex/categories.ts@@ -142,8 +142,7 @@ export const validateCategoryRemoval = internalQuery({throw new Error('Not found')const child = await ctx.db.query('categories')- .withIndex('by_user', q => q.eq('userId', userId))- .filter(q => q.eq(q.field('parentId'), id))+ .withIndex('by_user_parent', q => q.eq('userId', userId).eq('parentId', id)).first()if (child)throw new Error('Cannot delete category with children')diff --git a/convex/rates.ts b/convex/rates.tsindex 3b325753..4ed27804 100644--- a/convex/rates.ts+++ b/convex/rates.ts@@ -19,7 +19,7 @@ export const getLatest = query({export const saveRates = internalMutation({args: {date: v.string(),- rates: v.any(),+ rates: v.record(v.string(), v.number()),},handler: async (ctx, { date, rates }) => {const existing = await ctx.dbdiff --git a/convex/schema.ts b/convex/schema.tsindex 532bb18c..08508898 100644--- a/convex/schema.ts+++ b/convex/schema.ts@@ -15,11 +15,12 @@ export default defineSchema({userId: v.string(),}).index('by_user', ['userId'])- .index('by_user_name_parent', ['userId', 'name', 'parentId']),+ .index('by_user_name_parent', ['userId', 'name', 'parentId'])+ .index('by_user_parent', ['userId', 'parentId']),rates: defineTable({date: v.string(),- rates: v.any(),+ rates: v.record(v.string(), v.number()),updatedAt: v.number(),}).index('by_date', ['date']),