Custom/composite IDs as relation references

I am exploring Prisma as an alternative to our current ORM/backend, Parse, due to it not being very well maintained. Overall, the migration is looking pretty clean, but I'm running into an issue around translating the way Parse did relations and the way Prisma does them (this is for a Mongo database). Parse does it by having a relation field (or "pointer") with a composite key string value of ClassName$RecordID (i.e., Author$a43fE3f3) instead of the way Prisma does it where you define the class as a separate relation type field not stored in the DB. So my question is: is it possible to do this sort of custom relation reference value and, if so, how? The only other way I can imagine getting around this issue is to backfill a new ID fields onto every record with a relation in my database which just isn't feasible.
2 Replies
Prisma AI Help
Prisma AI Help2mo ago
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into #ask-ai for a quick spin!
RaphaelEtim
RaphaelEtim2mo ago
Hi @PocketColin
is it possible to do this sort of custom relation reference value and, if so, how?
It's not possible to do this in Prisma. You might want to take a look at adding missing relations after you might have introspected your mongodb database in Prisma.
MongoDB database connector | Prisma Documentation
How Prisma can connect to a MongoDB database using the MongoDB database connector.

Did you find this page helpful?