Seeking Solace
Seeking Solace2mo ago

"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"]),
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;
},
});
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.
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.
Database Relationship Helpers
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...
4 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Seeking Solace
Seeking SolaceOP2mo ago
I restarted the editor and the problem magically resolved itself. It seems that the 6th "required" argument "fieldArg" was a hallucination.
lee
lee2mo ago
the sixth argument is field, which would be required if your index were like index("userId", ["someOtherFieldName"]) https://github.com/get-convex/convex-helpers/blob/ada115ccb530bfb32b8aeb02c601c709a19619ed/packages/convex-helpers/server/relationships.ts#L121
GitHub
convex-helpers/packages/convex-helpers/server/relationships.ts at a...
A collection of useful code to complement the official packages. - get-convex/convex-helpers
Seeking Solace
Seeking SolaceOP2mo ago
Ah, I see. Thank you! You guys are saints, I appreciate your time.

Did you find this page helpful?