Need Help with CRUD operations
Hey devs, I have been facing this error where my component expects a user ID which was not provided. I need to refractor my backend and all so that my app doesn't need a user ID to make any CRUD operation. The more I am doing the changes, the more I am getting more errors. I am new to Prisma. Can someone help me out, please?
4 Replies
Hi @TheBwoyProgrammer
Thanks for choosing Prisma 🎉 .
What specific errors or issues are you seeing as you make these changes? Can you also share the relevant parts of your code? For example, schema, the query etc
Which user, the one making the request or the id of the record you are trying to modify? I'm guessing the former, but you never know.
If it's the former that users id is often encoded into a jwt. You can encode other things in there, but the tl;dr of it is, is that if it is you can devise some permissions.
eg, a user has a relation to some parent object like a company, that company has assets, therefor you check if the user has access to the parent of the record in question, and if so allow them to do stuff, if not, return a 403 is how I usually do it
You usually don't want to go ham encoding like a meg of stuff in a jwt, but in my last project I did encode the main parent objects id's as an array to make lookups and RBAC checks easier.
Hey @RaphaelEtim and @Yetzederixx thanks for the response. I have fixed the issue and it was about the queries formation
Great to here this is resolved.