Replies: 3 comments
-
|
In my opinion, we don't need to use the |
Beta Was this translation helpful? Give feedback.
-
|
I have another solution that doesn't require changing the MongoDB Provider. When we delete, we can delete the content and the shown authorName. here is an example comment tree. (the id's of the comments were indicated as #.id) after we delete the #.1 comment the comment tree will look like this. with that approach, we can also delete comments on account deletion. Here is another tree for that |
Beta Was this translation helpful? Give feedback.
-
|
A solution prisma/prisma#17746 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, Prisma for MongoDB has some problems with relational fields and cycles. The main problem with MongoDB and Prisma is in the comment system there is a self-relation in a comment model.
There is an ideal model for the comment.
Take a look at the
Cascadevalue in theonUpdateandonDeletevalues. TheCascadebasically means do the same thing for me. For example, if we delete the parent, we will delete this comment too, and the same thing applies toonUpdatetoo. If the parent changes its id then update myparentIdtoo.But eventually, this cannot be achieved that easily because Prisma for MongoDB doesn't support self-relations except relation's
onUpdateandonDeleteactions set toNoAction. I think it's a deal-breaker for us but here I am for the discussions.What if we switch to a fully supported Prisma connector?
That way we can freely use the full potential of the prisma while enjoying its beautiful schema and ORM system. But must keep in mind that this approach requires a lot of work and a lot of changes in the Data layer which can break most things.
Few examples of the problems:
Beta Was this translation helpful? Give feedback.
All reactions