JRPG AddictJ
Convex Community13mo ago
4 replies
JRPG Addict

"getManyViaOrThrow" Convex Helper Function Expects 6 Arguments

Relevant Schema:
  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"]),
  boards: defineTable({
    title: v.string(),
  }),
  userBoards: defineTable({
    userId: v.id("users"),
    boardId: v.id("boards"),
  })
    .index("userId", ["userId"])
    .index("boardId", ["boardId"]),

Mutation:
export const getUserBoards = query({
  args: {},
  handler: async (ctx) => {
    const userId = await getAuthUserId(ctx);
    if (!userId) {
      throw new Error("Not authenticated");
    }

    const boards = await getManyViaOrThrow(ctx.db, "userBoards", "boardId", "userId", userId);
    return boards;
  },
});

Error:
Expected 6 arguments, but got 5.ts(2554)
relationships.d.ts(157, 618): Arguments for the rest parameter 'fieldArg' were not provided.

I have thoroughly read the "Database Relationships Helpers" article:
https://stack.convex.dev/functional-relationships-helpers
But I can't find an example where he uses 6 arguments, nor can I find any examples or documentation that lists the 6 required arguments.
Traverse database relationships in a readable, predictable, and debuggable way. Support for one-to-one, one-to-many, and many-to-many via utility func...
Database Relationship Helpers
Was this page helpful?