From 8c62780dcbfa32f257538c5eb07212b05f88c81c Mon Sep 17 00:00:00 2001 From: gibbyb Date: Thu, 26 Mar 2026 10:02:21 -0500 Subject: [PATCH] Update the schema.ts to be more like the one on stpeteit --- packages/backend/convex/schema.ts | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/backend/convex/schema.ts b/packages/backend/convex/schema.ts index 056457f..e209836 100644 --- a/packages/backend/convex/schema.ts +++ b/packages/backend/convex/schema.ts @@ -3,22 +3,12 @@ import { defineSchema, defineTable } from 'convex/server'; import { v } from 'convex/values'; const applicationTables = { - // Users contains name image & email. - // If you would like to save any other information, - // I would recommend including this profiles table - // where you can include settings & anything else you would like tied to the user. - profiles: defineTable({ - userId: v.id('users'), - theme_preference: v.optional(v.string()), - }).index('userId', ['userId']), -}; - -export default defineSchema({ - ...authTables, - // Default table for users directly from authTable. - // You can extend it if you would like, but it may - // be better to just use the profiles table example - // below. + /* + * Below is the users table definition from authTables + * You can add additional fields here. You can also remove + * the users table here & create a 'profiles' table if you + * prefer to keep auth data separate from application data. + */ users: defineTable({ name: v.optional(v.string()), image: v.optional(v.string()), @@ -27,9 +17,20 @@ export default defineSchema({ phone: v.optional(v.string()), phoneVerificationTime: v.optional(v.number()), isAnonymous: v.optional(v.boolean()), + /* Fields below here are custom & not defined in authTables */ + themePreference: v.optional(v.union( + v.literal('light'), + v.literal('dark'), + v.literal('system'), + )), }) .index('email', ['email']) - .index('name', ['name']) - .index('phone', ['phone']), + .index('phone', ['phone']) + /* Indexes below here are custom & not defined in authTables */ + .index('name', ['name']), +}; + +export default defineSchema({ + ...authTables, ...applicationTables, });