-
Notifications
You must be signed in to change notification settings - Fork 742
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
Update 063-excluding-fields.mdx #5383
base: main
Are you sure you want to change the base?
Conversation
Update exclude function to make it short and compatible with typescript version 4.4+
@mubaidr is attempting to deploy a commit to the Prisma Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mubaidr, thanks a lot for this PR 🙏 it looks great 💚
I tested the code and it worked on my machine 🎉
The main concern I have is that it changes the signature of the exclude
function and now only allows to exclude a single key, i.e. exclude(user, 'password')
instead of multiple keys (passed as an array), e.g. exclude(user, ['id', 'password'])
as it's intended.
- Would you be able to update this and make the
exclude
function accept an array of keys? - Also, can you please make the input
obj
optional? - And finally (since you're on it): This didn't come from your PR but I noticed that the example in
main
actually doesn't run 🤦
It currently has the following query:
const user = await prisma.user.findUnique({ where: 1 })
but it should be:
const user = await prisma.user.findUnique({
where: {
id: 1
}
})
Thanks for caring about our docs and taking the time to improve them, that's much appreciated!!
Object.entries(user).filter(([key]) => !keys.includes(key)) | ||
) | ||
function exclude<T extends object, K extends keyof T>( | ||
obj: T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this optional?
obj: T, | |
obj: T | null, |
) | ||
function exclude<T extends object, K extends keyof T>( | ||
obj: T, | ||
key: K, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to keep this as K[]
?
Describe this PR
Update exclude function to make it short and compatible with typescript version 4.4+
Changes
Just updated example
exclude
function definitionWhat issue does this fix?
Exclude function does not support latest typescript version, gives warnings.
Any other relevant information
N/A