You’re running into a type error because you’re mixing two different patterns:
- Convex Auth (
authTables), where Convex manages a users table for you.
- Manual “users” table with
tokenIdentifier + by_token index, as shown in the non‑Convex‑Auth docs. [Storing users]
With Convex Auth, you don’t have a tokenIdentifier field or a by_token index on the auth users table, so TypeScript correctly complains.
How to get the current user with Convex Auth
When using Convex Auth, you should use getAuthUserId instead of querying by tokenIdentifier yourself. [Use auth state]
Example:
import { query } from "./_generated/server";
import { getAuthUserId } from "@convex-dev/auth/server";
export const listAssignedIssues = query({
args: {},
async handler(ctx) {
const userId = await getAuthUserId(ctx);
if (userId === null) return [];
return ctx.db
.query("issues")
.withIndex("by_assignee", (q) => q.eq("assignee", userId))
.collect();
},
});
Key points:
getAuthUserId(ctx) returns the Convex users document ID (or null if not signed in). [Use auth state]
- Your
"issues" table’s assignee field should be v.id("users"), and your by_assignee index should be defined on that field.
- You no longer need a
by_token index or a tokenIdentifier field when using Convex Auth’s authTables.