Skip to content
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

fix: group by #4768

Merged
merged 7 commits into from
Dec 28, 2020
Merged

fix: group by #4768

merged 7 commits into from
Dec 28, 2020

Conversation

timsuchanek
Copy link
Contributor

@timsuchanek timsuchanek commented Dec 22, 2020

Add type constraints for the following cases:

  1. If take or skip is provided, orderBy is required
  2. Anything in orderBy needs to be in by

Introduces tsd to write type error tests.

@timsuchanek timsuchanek changed the title wip: new types fix: group by Dec 28, 2020
@timsuchanek timsuchanek added this to the 2.14.0 milestone Dec 28, 2020
@timsuchanek timsuchanek marked this pull request as ready for review December 28, 2020 11:43
@timsuchanek timsuchanek merged commit 053c5d1 into master Dec 28, 2020
@timsuchanek timsuchanek deleted the fix-groupby branch December 28, 2020 14:25
Comment on lines +64 to +77
body: (ctx) => `Group by ${ctx.singular}.
@param {${getGroupByArgsName(ctx.model.name)}} args - Group by arguments.
@example
// Group by city, order by createdAt, get count
const result = await prisma.user.groupBy({
by: ['city', 'createdAt'],
orderBy: {
createdAt: true
},
count: {
_all: true
},
})
`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks hardcoded @timsuchanek should be dynamic no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally did a hardcoded example here, as it's otherwise quite hard to auto generate the jsdocs (we need to find the right fields, check if they're even there etc).
So I chose an example that always makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants