Shivam Singh
04/28/2022, 9:55 AMprisma.create
on this model do I need to provide both createdBy
and owner
or either of them?Nurul
04/28/2022, 11:22 AMowner
seems to be a relation field so you could skip it.Shivam Singh
04/28/2022, 12:37 PMconnect
for F Keys.Nurul
04/28/2022, 12:51 PMconnect
clause. This is considered unsafe because Prisma doesn’t validate if the id that you are passing in the createdBy field actually exists in the User table or not.
2. Using connect
clause, here instead of setting createdBy directly you could use the owner field to connect this record to the User model, this is considered as safe because is you are passing a user id which doesn’t exist in User model Prisma would throw an error, so you have an extra layer of validation.