Have the developers considered allowing more optio...
# orm-help
a
Have the developers considered allowing more options when creating an item in order to enforce foreign keys deeper in the model hierarchy? Let’s say I have ModelA which has many ModelB which has many ModelC. I want to allow a user to create an instance of ModelC but only if a key belonging to the user, let’s call it companyId, matches the companyId of an instance of ModelA. In order to do that I have to use prisma.modela.update() because when invoking prisma.modelc.create() I can only connect it to neighboring models which in this case would be ModelB.
What I’m saying is that it would be useful to include the options for where in create.
So apparently that might not be feasible since the SQL specification doesn’t support specifying WHERE on an INSERT. What’s the answer then?
r
I doubt whether Prisma will include this if the SQL specification doesn’t support it. So the best way in my opinion would be two queries, 1 for checking if the
id
matches and the other for insertion. Still, I would suggest creating a feature request here so that we can look into it.
a
Created an issue.
💯 1