Files
fyp/packages/backend/convex/schema.ts

37 lines
1.2 KiB
TypeScript

import { defineSchema, defineTable } from 'convex/server';
import { v } from 'convex/values';
import { authTables } from '@convex-dev/auth/server';
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.
users: defineTable({
name: v.optional(v.string()),
image: v.optional(v.string()),
email: v.optional(v.string()),
emailVerificationTime: v.optional(v.number()),
phone: v.optional(v.string()),
phoneVerificationTime: v.optional(v.number()),
isAnonymous: v.optional(v.boolean()),
})
.index("email", ["email"])
.index('name', ['name'])
.index("phone", ["phone"]),
...applicationTables,
});