IssueRaiser

Support `distinct` in `count()`

## Problem I have bumped into a few cases where I need to do a 'where' filter and get records that are 'distinct', to add pagination I need to do a count query also with a 'distinct' option on 'count()', based on the documentation and experience, I can't use distinct on a count() ``` export type FindManyUserArgs = { where?: UserWhereInput | null orderBy?: Enumerable<UserOrderByInput> | null skip?: number | null after?: UserWhereUniqueInput | null before?: UserWhereUniqueInput | null first?: number | null last?: number | null } ``` ## Suggested solution Can we update count() to support distinct as well? so it would accept the object similar to findMany() ``` export type FindManyUserArgs = { select?: UserSelect | null include?: UserInclude | null where?: UserWhereInput | null orderBy?: Enumerable<UserOrderByInput> | null cursor?: UserWhereUniqueInput | null take?: number | null skip?: number | null distinct?: Enumerable<UserDistinctFieldEnum> } ```

Posted by DregondRahl on Nov 11, 2020, 4:00 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

support (Other)

Support `distinct` in `count()`

DregondRahlNov 11, 2020, 4:00 PM

## Problem I have bumped into a few cases where I need to do a 'where' filter and get records that are 'distinct', to add pagination I need to do a count query also with a 'distinct' option on 'count()', based on the documentation and experience, I can't use distinct on a count() ``` export type FindManyUserArgs = { where?: UserWhereInput | null orderBy?: Enumerable<UserOrderByInput> | null skip?: number | null after?: UserWhereUniqueInput | null before?: UserWhereUniqueInput | null first?: number | null last?: number | null } ``` ## Suggested solution Can we update count() to support distinct as well? so it would accept the object similar to findMany() ``` export type FindManyUserArgs = { select?: UserSelect | null include?: UserInclude | null where?: UserWhereInput | null orderBy?: Enumerable<UserOrderByInput> | null cursor?: UserWhereUniqueInput | null take?: number | null skip?: number | null distinct?: Enumerable<UserDistinctFieldEnum> } ```

Comments (0)

No comments yet. Start the discussion.

Comment on this issue