-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
how can i exclude a field while finding model. #920
Comments
It's not possible yet in the Go client. Can you please describe why you want this feature? Is there a big field which you want to exclude for performance? also see #346 for selecting fields |
i dont want to user see hashedpassword |
Good point! I'll put this into the 'soon' list, it would be indeed cool if specific fields could be ignored. However, note that specifically excluding fields might a bit dangerous as the default is returning all, so you might be better off to just selecting the fields you want. This is also not supported yet, but you can work around this by defining a new struct which just returns the fields you want: user, err := db.User.FindUnique(...).Exec(ctx)
u := struct{
Name string `json:"string"`
}{
Name: user.Name,
}
// do something with u
return u or user, err := db.User.FindUnique(...).Exec(ctx)
newUser := db.UserModel{
ID: user.ID,
Name: user.Name,
}
return newUser |
thank you for suggestion |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@steebchen any news on this feature? even with your suggestions, its a pain when you have to use FindMany as it adds a lot of unnecessary operations |
Not sure what you mean by "have to use FindMany". Using structs is indeed not ideal I'm currently working on a few Go client things, feel free to sponsor me (or ask your employer) to potentially speed things up ;) |
Regarding the implementation, it would most likely implementing select instead of implementing an exclude function (similar to what the JS client does). |
how can i do this? i can do this in javascript using select field. how can i do this in go client???
The text was updated successfully, but these errors were encountered: