How can I create an explicit many-to-many connection, if it doesn't already exist? #13964
Replies: 2 comments 5 replies
-
|
Hey @lumenwrites 👋, Have you taken a look at our |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm working on a platform for selling courses. I have a
Coursemodel,Profilemodel, and aPurchasemodel - an explicit many-to-many connection between theCourseandProfilerepresenting the fact that the user has purchased the course.My goal is to create this connection, but only if it doesn't already exist (adding the course to the list of courses purchased by users, but only if he hasn't purchased it already).
Here are my models:
And here's how I'm making the connection right now:
The problem is that this code throws an error if the connection already exists (if the user has purchased the course before).
Does Prisma have some sort of command that creates a connection if one isn't already in place?
Beta Was this translation helpful? Give feedback.
All reactions