styleS
Convex Community2mo ago
3 replies
style

using functions from betterAuth component

Hi, I'm trying to get user on server.I cannot follow normal path with getUserIdentity as I use it in cronjob. How do i use function from different component or how do i query table in different component?

I've tried importing it's generated api but it's not working:
smsyjyazn3s7vmadb:' [Error: Could not find public function for 'adapter:findOne'. Did you forget to run `npx convex dev` or `npx convex deploy`?]


code:
import { api } from '../betterAuth/_generated/api'

/**
 * Get user info by userId (internal query)
 */
export const _internalGetUserInfo = internalQuery({
  args: {
    userId: v.string(),
  },
  returns: v.union(
    v.object({
      email: v.string(),
      name: v.string(),
    }),
    v.null(),
  ),
  handler: async (ctx, args) => {
    try {
      // Use the adapter's findOne to query the better-auth user table
      // This works without authentication since we're querying directly
      const user = await ctx.runQuery(api.adapter.findOne, {
        model: 'user',
        where: [
          {
            field: 'id',
            operator: 'eq',
            value: args.userId,
          },
        ],
      })
Was this page helpful?