rutenisraila
rutenisraila•17mo ago

missing delete mutation example in the docs

Hey guys, I've been checking out convex. I managed to do auth, get and post operations. But I can't seem to find docs on how to delete an item from a table. I've attached the type error I'm getting. I'm also attaching the post mutation which works fine. If there're docs for this, please point me to them, thanks!
No description
No description
13 Replies
jamwt
jamwt•17mo ago
hey @rutenisraila ! thanks for trying convex ids are database-unique. every id is the only id with that value in the whole database, not just for the table in fact, ids embed information in them that lets convex know which table the id came from
jamwt
jamwt•17mo ago
so, the delete method doesn't need the table name. only the id. https://docs.convex.dev/api/interfaces/server.DatabaseWriter#delete
jamwt
jamwt•17mo ago
if you remove the 'decisions' argument from that method, everything should work
rutenisraila
rutenisrailaOP•17mo ago
hi Jamie, thanks for the fast response, that's what I initially tried, but I get this type error:
No description
rutenisraila
rutenisrailaOP•17mo ago
am I missing something?
jamwt
jamwt•17mo ago
GitHub
convex-demos/relational-data-modeling/README.md at c0d84a85e533ed6f...
Demo apps built on Convex. Contribute to get-convex/convex-demos development by creating an account on GitHub.
jamwt
jamwt•17mo ago
in your case I suppose it's a v.id('decisions') this just gives you even more type safety that you're actually passing an id from the proper table into your convex functions
rutenisraila
rutenisrailaOP•17mo ago
yooo, it works! Thanks for help Jamie. Keep up the great work!
jamwt
jamwt•17mo ago
glad to hear it!
Michal Srb
Michal Srb•17mo ago
The docs for delete are here, including validator example: https://docs.convex.dev/database/writing-data#deleting-documents Let us know if you had trouble finding this with the docs search.
Writing Data | Convex Developer Hub
Mutations can insert, update, and
rutenisraila
rutenisrailaOP•17mo ago
hi @Michal Srb thanks for the docs link! one thing that took me a bit of time to get used to is that in convex folder I have to reference type with "v", and in the app code I have to import them _generated/dataModel. I think I saw it somewhere else in the docs, but not in the delete. Anyways, still a really cool product I love the analytics dashboard. This makes feel cloud function development achievable for mortals, I've been having a lot of fun 😄
No description
stefano
stefano•7mo ago
is there a way for us to know this too? Having an id and knowing which table it comes from
Michal Srb
Michal Srb•7mo ago
@stefano we don’t expose this atm, no, leaving the option to make ids not include their tables index for the future. You should be able to work around this by storing and processing a table name along with your id.

Did you find this page helpful?