convex-backend icon indicating copy to clipboard operation
convex-backend copied to clipboard

The convex function cannot get the field type of the convex-auth extension users table

Open youwei997 opened this issue 2 months ago • 1 comments

Convex combined with convex-auth. I override and extend the users table in authTables in the schema, but I can't get the type of the extended field in the function

schema.ts

import { authTables } from '@convex-dev/auth/server'
import { defineSchema, defineTable } from 'convex/server'
import { v } from 'convex/values'

const schema = defineSchema({
  ...authTables,
  users: defineTable({
    email: v.optional(v.string()),
    image: v.optional(v.string()),
    isAnonymous: v.optional(v.boolean()),
    name: v.optional(v.string()),
    phone: v.optional(v.string()),
    role: v.optional(v.string()),
    parentId: v.optional(v.id('users')),
    status: v.optional(v.string()), // 用户状态,例如 'active', 'inactive'
  })
    .index('email', ['email'])
    .index('parentId', ['parentId']),

export default schema

users.ts

import { createAccount, type Doc, getAuthUserId, modifyAccountCredentials } from '@convex-dev/auth/server'
import { v } from 'convex/values'
import { api, internal } from './_generated/api'
import { action, internalMutation, internalQuery, mutation, query } from './_generated/server'

type ReturnUser = Doc<'users'>

Image Look at types that don't have role, parentId, status

Is this normal?thank you

youwei997 avatar Sep 23 '25 05:09 youwei997

Are you running npx convex dev? It looks like your generated types are out of date.

nipunn1313 avatar Sep 25 '25 23:09 nipunn1313