Prisma-client-js: Explicit relation tables

Created on 19 Jul 2019  路  8Comments  路  Source: prisma/prisma-client-js

As far as I aware of, the following feature from Prisma:

type MyRelation @relationTable {
  user: User!
  profile: Profile!
}

is somehow implemented in Prisma2. But there is no documentation. How to use it?

kinfeature AUMFIDARR

Most helpful comment

@divyenduz : We are working on it right now. But it will take a few more weeks until this will be finished.

All 8 comments

Hey @victordombrovskiy, thanks for opening this issue. This topic indeed lacks proper documentation at the moment. You can however learn about the intended behaviour in our spec here.

In short: The @relationTable attribute is not needed any more. Instead you define a relation table in the same way you'd define any other model:

model MyRelation {
  user User
  profile Profile

  @@id([user, profile])
}

UPDATE: I just talked to @mavilein about this feature. Defining relation tables like this is actually not implemented yet. The query engine has the assumption that every model has a singular id field. This is not the case for thise use case, therefore it doesn't work yet.

@nikolasburk will it be included in the today's release? Or when do you this will be fixed? Just want to plan further work based on availability of this feature.

It won't be included in today's release and might take a few more weeks (possibly months) until it is available.

We dropped this for now but this will be picked up again in coming weeks. We have noted that community wants this feature. It is blocked on some internal refactoring around supporting multiple unique ids and would be picked up in a bigger epic.

@divyenduz What is status of this? A lot of weeks passed :)
Probably, you can suggest a best way to workaround this limitation?

@victordombrovskiy If I understand it correctly, this feature is being worked on from the perspective of introspection https://github.com/prisma/prisma2/issues/1083 and is in the current milestone.

@divyenduz : We are working on it right now. But it will take a few more weeks until this will be finished.

This is now implemented and can be used with the syntac @nikolasburk posted above 馃殌

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrmntte picture mrmntte  路  3Comments

emroot picture emroot  路  4Comments

FluorescentHallucinogen picture FluorescentHallucinogen  路  3Comments

divyenduz picture divyenduz  路  3Comments

nikolasburk picture nikolasburk  路  3Comments