Next.js Discord

Discord Forum

Checkbox value depending on postgressql database entry, using prisma

Unanswered
Pollock posted this in #help-forum
Open in Discord
PollockOP
Hello, im trying to build a todo app, and for that i have a bunch of postgressql todo entries with initial status value of False.
I want to have a checkbox for each entry that is checked automatically if the status is true and unchecked if false. If i check or uncheck the box the status is immediately saved to the postgressql database, so kinda synchronous to the database. Im using prisma as the orm.

Im kinda not finding anything useful on the web... How would u implement that, or atleast what do i have to search on the web

1 Reply

@Pollock Hello, im trying to build a todo app, and for that i have a bunch of postgressql todo entries with initial status value of False. I want to have a checkbox for each entry that is checked automatically if the status is true and unchecked if false. If i check or uncheck the box the status is immediately saved to the postgressql database, so kinda synchronous to the database. Im using prisma as the orm. Im kinda not finding anything useful on the web... How would u implement that, or atleast what do i have to search on the web
West African Lion
To implement a checkbox feature in your todo app that synchronizes with a PostgreSQL database using Prisma ORM, start by ensuring your database schema includes a todos table with the relevant id, title, and a status column of boolean type. Utilize Prisma to fetch the todo entries on the frontend, rendering a checkbox for each entry that reflects its current status. Implement a change handler function that triggers on checkbox toggle, updating the corresponding entry in the database through Prisma's update method. For a seamless user experience, consider using optimistic updates by directly modifying the local state to reflect the change before the database confirmation. Don't forget to include error handling to manage any potential issues during the database interaction, ensuring robust functionality in your app. This approach not only keeps your frontend responsive but also maintains data integrity between the server and client states.