Update the schema.ts to be more like the one on stpeteit

This commit is contained in:
2026-03-26 10:02:21 -05:00
parent 2d0a34347b
commit 8c62780dcb

View File

@@ -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,
});