-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
exclude column form selection (Hidden Columns) @select(false)
#3636
Comments
@satishbabariya Thank you for raising this ticket. For now I have to omit them painstakingly like export type UserWhereInput = Omit<Prisma.UserWhereInput, 'password' | 'isActive'>; Note that Looking forward to this feature available with the preview flag. |
This comment has been minimized.
This comment has been minimized.
I can't express how important this feature is |
You are only omit the typing for those fields and not the actual fields in the select or result. So those fields would be, for example, still included in an API-Response. Or am I missing something here? |
This is especially dangerous because basically any manipulation, even deletion, in prisma is returning the complete selection of all fields. The moment you just think for a second writing your code, you stumble uppon this. I try to wrap my head around how this behavior, without any options to change it, could make it into a release and be ignored for so long. |
@benbender your are correct. The following is only enforcing the shape of the desired data. export type UserWhereInput = Omit<Prisma.UserWhereInput, 'password' | 'isActive'>; In turn, the Since Prisma cannot (at this time) exclude fields out-of-the-box, some acrobatic steps are performed to achieve a secure API. This is an example that does the job well for now - It will be removed once |
I'm also interested in having this solved. |
Closing in favor of #5042. We'll provide one solution for this whether it's in the schema or within the query is TBD. |
Problem
How can i exclude certain column form select query overall like Password in the User Model.
Currently i'm using
@Column({ select: false })
in typeorm.ref: https://github.com/satishbabariya/nodejs-boilerplate/blob/master/src/models/User.ts#L37
Is ther any way to do this in prisma2? like
reference of TypeORM: https://typeorm.io/#/select-query-builder/hidden-columns
The text was updated successfully, but these errors were encountered: