nicktsangN
Convex Community2mo ago
1 reply
nicktsang

Uncaught Error: Update on nonexistent document ID

🪲Bug ReportAdvice
Hello, I am trying to delete a document from a table. My code is below:

export const deleteTestimonial = mutation({
  args: { id: v.id("testimonials") },
  handler: async (ctx, {id}) => {
    const canDelete = await ctx.runQuery(api.auth.checkUserPermissions, {
      permissions: { testimonial: ["delete"] },
    });

    if (!canDelete) {
      throw new Error("Forbidden");
    }
    const doc = await ctx.db.get("testimonials", id);
    console.log("Doc before delete:", doc);
    await ctx.db.delete("testimonials", id);
  },
});

The logs show that the document with the id does exist, and I've also confirmed its existence in the database through convex's dashboard. What could be causing this issue, and what is the work around?
For reference, my convex versions are:
"convex": "^1.31.6",
"convex-helpers": "^0.1.111",
Was this page helpful?