-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore unique in connect objects? #28
Comments
I'm sorry, the prisma generator only parses triple-slash comments on fields and not on any /// some annotation
model Role {
id String @id
name Json
attribute String
companyUserRoles CompanyUserRole[]
@@unique([name, attribute])
} So basically, a model could be annotated with, for example, |
Hm I dont 't think this is a good way to do this, tbh. What if someone wants to only hide on a specific unique. Maybe its worth asking over at prisma if they every thought about implementing something like this. |
@Brakebein I see in an earlier comment you mentioned a To expand on that, when I add a second |
No, the annotation In general, if there are more than one unique field, then, of course, the ConnectDto properties are optional, because you can identify an entry by either one of the fields. In this regard, it just replicates what the Prisma client expects for connect clauses. There are two possible options to deal with your issue. It depends how you want it to be. Assuming following model: model Page {
id String @id
slug String @unique
} Do you want the export class ConnectPageDto {
id: string;
} Or do you just want the export class ConnectPageDto {
id: string;
slug?: string;
} In both cases, I would need to implement some additional annotation to control this behavior. For example |
In my case, the first scenario described would be preferred, where the connect dto would look like:
I dont want to be able to query by slug, but I do want it to be a unique constraint in the DB. Thanks! |
Please check out version 1.21.0-beta. If an |
Hi @Brakebein, just pulled down the beta version and it works perfect for my use case. Thank you for adding this in! |
With the latest release, I changed the annotation to |
Is it possible to implement the ignore annotations for the unique constraints like this?
The text was updated successfully, but these errors were encountered: