#questio

3 messages · Page 1 of 1 (latest)

boreal thorn
#

export const confirmUpload = internalMutation({
args: {
fileId: v.id("files"),
},
handler: async (ctx, args) => {
....
},
});
in this code does the argument auto validate and check if the fileID is actually valid and exist i nthe db

ivory brookBOT
#

Hi @boreal thorn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

No — v.id("files") only validates the type and table, not that a document with that ID actually exists.

What v.id("files") does:

  • Ensures the argument is a Convex Id<"files"> (i.e. a string shaped like a Convex document ID and associated with the files table). [Supported types; Document IDs]
  • This protects you from someone passing an ID from another table or a non-ID value.

What it does not do:

  • It does not check that there is a row in the files table with that ID. You still need to call ctx.db.get("files", args.fileId) and handle the null case yourself. [Document IDs]

So your function is type-validated, but existence must be checked explicitly in the handler.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: