Skip to content

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

@youwei997

Description

@youwei997

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions