[How To?] Create a record in database on form submission...
I have an application using trpc, Cloudfare D1 database, and trpc.
I am trying to use a tamagui form component to insert a record into the database.
My trpc route:
My drizzle table schema:
My form component:
When i click the form button, i get a 500 internal error on api/trpc side. Can someone tell me what I am doing wrong, i feel like its obvious but im not getting it.
2 Replies
Actually, looking now i can see an error:
on the trpc call.
I have a uuid field I created that is supposed to work with sqlite. Ill remove it and try to insert a record just using basic id and report back. If anyone has an implementation of binary uuids in sqlite id love to see it.
removed the uuid database column and all works as expected. Its some error im my implementation of uuids in sqlite, not a trpc issue.
if anyone has a method for storing uuids in a cloudflare d1 database, sqlite, let me know
Just searching through for something else but stumbled across your message.
Example of sqlite table for cloudflare:
It's not as performant as uuid on postgres but the purpose to use uuid in my case is to avoid that people can guess a sequence.
If there would be a need for a sortable id based on time, you could use uuidv7, there are some implementations, e.g. https://github.com/LiosK/uuidv7, but they are roughly 4x slower than uuid4.