From 02e8011c907df12b3d83020cbc0b034e2565c44f Mon Sep 17 00:00:00 2001 From: William Luke Date: Thu, 17 Dec 2020 13:05:10 +0300 Subject: [PATCH] feat(client): add more jsdoc to Prisma Client (#4388) --- .../__snapshots__/test.ts.snap | 1595 +++++++++++++++-- .../client/src/generation/TSClient/Args.ts | 15 +- .../client/src/generation/TSClient/Input.ts | 2 +- .../client/src/generation/TSClient/Model.ts | 54 +- .../src/generation/TSClient/constants.ts | 354 ++++ .../client/src/generation/TSClient/helpers.ts | 272 +-- src/packages/client/src/generation/utils.ts | 10 + src/packages/generator-helper/src/dmmf.ts | 4 + 8 files changed, 1941 insertions(+), 365 deletions(-) diff --git a/src/packages/client/src/__tests__/integration/happy/exhaustive-schema/__snapshots__/test.ts.snap b/src/packages/client/src/__tests__/integration/happy/exhaustive-schema/__snapshots__/test.ts.snap index 88d6e8fa4495..3086c0a6dc45 100644 --- a/src/packages/client/src/__tests__/integration/happy/exhaustive-schema/__snapshots__/test.ts.snap +++ b/src/packages/client/src/__tests__/integration/happy/exhaustive-schema/__snapshots__/test.ts.snap @@ -1315,15 +1315,63 @@ export namespace Prisma { } export type AggregatePostArgs = { + /** + * Filter which Post to aggregate. + **/ where?: PostWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Posts to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: PostWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Posts from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` Posts. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Posts + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: PostAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: PostSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: PostMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: PostMaxAggregateInputType } @@ -1577,18 +1625,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__PostClient | null>> /** - * Count - */ + * Count the number of Posts. + * @param {FindManyPostArgs} args - Arguments to filter Posts to count. + * @example + * // Count the number of Posts + * const count = await prisma.post.count({ + * where: { + * // ... the filter for the Posts we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a Post. + * @param {AggregatePostArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -1676,10 +1752,35 @@ export namespace Prisma { * Filter, which Post to fetch. **/ where?: PostWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Posts to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Posts. + **/ cursor?: PostWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Posts from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` Posts. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of Posts. + **/ distinct?: Enumerable } @@ -1701,18 +1802,26 @@ export namespace Prisma { **/ where?: PostWhereInput /** - * Determine the order of the Posts to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Posts to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing Posts. **/ cursor?: PostWhereUniqueInput /** - * The number of Posts to fetch. If negative number, it will take Posts before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Posts from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` Posts. **/ skip?: number @@ -1992,15 +2101,63 @@ export namespace Prisma { } export type AggregateUserArgs = { + /** + * Filter which User to aggregate. + **/ where?: UserWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Users to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: UserWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Users from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` Users. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Users + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: UserAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: UserSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: UserMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: UserMaxAggregateInputType } @@ -2270,18 +2427,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__UserClient | null>> /** - * Count - */ + * Count the number of Users. + * @param {FindManyUserArgs} args - Arguments to filter Users to count. + * @example + * // Count the number of Users + * const count = await prisma.user.count({ + * where: { + * // ... the filter for the Users we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a User. + * @param {AggregateUserArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -2369,10 +2554,35 @@ export namespace Prisma { * Filter, which User to fetch. **/ where?: UserWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Users to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Users. + **/ cursor?: UserWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Users from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` Users. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of Users. + **/ distinct?: Enumerable } @@ -2394,18 +2604,26 @@ export namespace Prisma { **/ where?: UserWhereInput /** - * Determine the order of the Users to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of Users to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing Users. **/ cursor?: UserWhereUniqueInput /** - * The number of Users to fetch. If negative number, it will take Users before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` Users from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` Users. **/ skip?: number @@ -2679,15 +2897,63 @@ export namespace Prisma { } export type AggregateMArgs = { + /** + * Filter which M to aggregate. + **/ where?: MWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of MS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: MWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` MS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` MS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned MS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: MAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: MSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: MMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: MMaxAggregateInputType } @@ -2955,18 +3221,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__MClient | null>> /** - * Count - */ + * Count the number of Ms. + * @param {FindManyMArgs} args - Arguments to filter Ms to count. + * @example + * // Count the number of Ms + * const count = await prisma.m.count({ + * where: { + * // ... the filter for the Ms we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a M. + * @param {AggregateMArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -3054,10 +3348,35 @@ export namespace Prisma { * Filter, which M to fetch. **/ where?: MWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of MS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for MS. + **/ cursor?: MWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` MS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` MS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of MS. + **/ distinct?: Enumerable } @@ -3079,18 +3398,26 @@ export namespace Prisma { **/ where?: MWhereInput /** - * Determine the order of the MS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of MS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing MS. **/ cursor?: MWhereUniqueInput /** - * The number of MS to fetch. If negative number, it will take MS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` MS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` MS. **/ skip?: number @@ -3364,15 +3691,63 @@ export namespace Prisma { } export type AggregateNArgs = { + /** + * Filter which N to aggregate. + **/ where?: NWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of NS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: NWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` NS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` NS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned NS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: NAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: NSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: NMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: NMaxAggregateInputType } @@ -3640,18 +4015,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__NClient | null>> /** - * Count - */ + * Count the number of Ns. + * @param {FindManyNArgs} args - Arguments to filter Ns to count. + * @example + * // Count the number of Ns + * const count = await prisma.n.count({ + * where: { + * // ... the filter for the Ns we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a N. + * @param {AggregateNArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -3739,10 +4142,35 @@ export namespace Prisma { * Filter, which N to fetch. **/ where?: NWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of NS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for NS. + **/ cursor?: NWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` NS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` NS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of NS. + **/ distinct?: Enumerable } @@ -3764,18 +4192,26 @@ export namespace Prisma { **/ where?: NWhereInput /** - * Determine the order of the NS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of NS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing NS. **/ cursor?: NWhereUniqueInput /** - * The number of NS to fetch. If negative number, it will take NS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` NS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` NS. **/ skip?: number @@ -4049,15 +4485,63 @@ export namespace Prisma { } export type AggregateOneOptionalArgs = { + /** + * Filter which OneOptional to aggregate. + **/ where?: OneOptionalWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OneOptionals to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: OneOptionalWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OneOptionals from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OneOptionals. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned OneOptionals + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: OneOptionalAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: OneOptionalSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: OneOptionalMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: OneOptionalMaxAggregateInputType } @@ -4325,18 +4809,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__OneOptionalClient | null>> /** - * Count - */ + * Count the number of OneOptionals. + * @param {FindManyOneOptionalArgs} args - Arguments to filter OneOptionals to count. + * @example + * // Count the number of OneOptionals + * const count = await prisma.oneOptional.count({ + * where: { + * // ... the filter for the OneOptionals we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a OneOptional. + * @param {AggregateOneOptionalArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -4424,10 +4936,35 @@ export namespace Prisma { * Filter, which OneOptional to fetch. **/ where?: OneOptionalWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OneOptionals to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for OneOptionals. + **/ cursor?: OneOptionalWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OneOptionals from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OneOptionals. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of OneOptionals. + **/ distinct?: Enumerable } @@ -4449,18 +4986,26 @@ export namespace Prisma { **/ where?: OneOptionalWhereInput /** - * Determine the order of the OneOptionals to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OneOptionals to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing OneOptionals. **/ cursor?: OneOptionalWhereUniqueInput /** - * The number of OneOptionals to fetch. If negative number, it will take OneOptionals before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OneOptionals from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` OneOptionals. **/ skip?: number @@ -4744,15 +5289,63 @@ export namespace Prisma { } export type AggregateManyRequiredArgs = { + /** + * Filter which ManyRequired to aggregate. + **/ where?: ManyRequiredWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ManyRequireds to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: ManyRequiredWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ManyRequireds from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` ManyRequireds. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned ManyRequireds + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: ManyRequiredAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: ManyRequiredSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: ManyRequiredMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: ManyRequiredMaxAggregateInputType } @@ -5022,18 +5615,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__ManyRequiredClient | null>> /** - * Count - */ + * Count the number of ManyRequireds. + * @param {FindManyManyRequiredArgs} args - Arguments to filter ManyRequireds to count. + * @example + * // Count the number of ManyRequireds + * const count = await prisma.manyRequired.count({ + * where: { + * // ... the filter for the ManyRequireds we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a ManyRequired. + * @param {AggregateManyRequiredArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -5121,10 +5742,35 @@ export namespace Prisma { * Filter, which ManyRequired to fetch. **/ where?: ManyRequiredWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ManyRequireds to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for ManyRequireds. + **/ cursor?: ManyRequiredWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ManyRequireds from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` ManyRequireds. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of ManyRequireds. + **/ distinct?: Enumerable } @@ -5146,18 +5792,26 @@ export namespace Prisma { **/ where?: ManyRequiredWhereInput /** - * Determine the order of the ManyRequireds to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ManyRequireds to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing ManyRequireds. **/ cursor?: ManyRequiredWhereUniqueInput /** - * The number of ManyRequireds to fetch. If negative number, it will take ManyRequireds before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ManyRequireds from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` ManyRequireds. **/ skip?: number @@ -5441,15 +6095,63 @@ export namespace Prisma { } export type AggregateOptionalSide1Args = { + /** + * Filter which OptionalSide1 to aggregate. + **/ where?: OptionalSide1WhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide1s to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: OptionalSide1WhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide1s from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OptionalSide1s. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned OptionalSide1s + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: OptionalSide1AvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: OptionalSide1SumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: OptionalSide1MinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: OptionalSide1MaxAggregateInputType } @@ -5719,18 +6421,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__OptionalSide1Client | null>> /** - * Count - */ + * Count the number of OptionalSide1s. + * @param {FindManyOptionalSide1Args} args - Arguments to filter OptionalSide1s to count. + * @example + * // Count the number of OptionalSide1s + * const count = await prisma.optionalSide1.count({ + * where: { + * // ... the filter for the OptionalSide1s we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a OptionalSide1. + * @param {AggregateOptionalSide1Args} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -5818,10 +6548,35 @@ export namespace Prisma { * Filter, which OptionalSide1 to fetch. **/ where?: OptionalSide1WhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide1s to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for OptionalSide1s. + **/ cursor?: OptionalSide1WhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide1s from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OptionalSide1s. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of OptionalSide1s. + **/ distinct?: Enumerable } @@ -5843,18 +6598,26 @@ export namespace Prisma { **/ where?: OptionalSide1WhereInput /** - * Determine the order of the OptionalSide1s to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide1s to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing OptionalSide1s. **/ cursor?: OptionalSide1WhereUniqueInput /** - * The number of OptionalSide1s to fetch. If negative number, it will take OptionalSide1s before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide1s from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` OptionalSide1s. **/ skip?: number @@ -6128,15 +6891,63 @@ export namespace Prisma { } export type AggregateOptionalSide2Args = { + /** + * Filter which OptionalSide2 to aggregate. + **/ where?: OptionalSide2WhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide2s to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: OptionalSide2WhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide2s from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OptionalSide2s. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned OptionalSide2s + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: OptionalSide2AvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: OptionalSide2SumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: OptionalSide2MinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: OptionalSide2MaxAggregateInputType } @@ -6404,18 +7215,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__OptionalSide2Client | null>> /** - * Count - */ + * Count the number of OptionalSide2s. + * @param {FindManyOptionalSide2Args} args - Arguments to filter OptionalSide2s to count. + * @example + * // Count the number of OptionalSide2s + * const count = await prisma.optionalSide2.count({ + * where: { + * // ... the filter for the OptionalSide2s we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a OptionalSide2. + * @param {AggregateOptionalSide2Args} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -6503,10 +7342,35 @@ export namespace Prisma { * Filter, which OptionalSide2 to fetch. **/ where?: OptionalSide2WhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide2s to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for OptionalSide2s. + **/ cursor?: OptionalSide2WhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide2s from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` OptionalSide2s. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of OptionalSide2s. + **/ distinct?: Enumerable } @@ -6528,18 +7392,26 @@ export namespace Prisma { **/ where?: OptionalSide2WhereInput /** - * Determine the order of the OptionalSide2s to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of OptionalSide2s to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing OptionalSide2s. **/ cursor?: OptionalSide2WhereUniqueInput /** - * The number of OptionalSide2s to fetch. If negative number, it will take OptionalSide2s before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` OptionalSide2s from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` OptionalSide2s. **/ skip?: number @@ -6823,15 +7695,63 @@ export namespace Prisma { } export type AggregateAArgs = { + /** + * Filter which A to aggregate. + **/ where?: AWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of AS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: AWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` AS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` AS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned AS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: AAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: ASumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: AMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: AMaxAggregateInputType } @@ -7087,18 +8007,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__AClient | null>> /** - * Count - */ + * Count the number of As. + * @param {FindManyAArgs} args - Arguments to filter As to count. + * @example + * // Count the number of As + * const count = await prisma.a.count({ + * where: { + * // ... the filter for the As we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a A. + * @param {AggregateAArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -7177,10 +8125,35 @@ export namespace Prisma { * Filter, which A to fetch. **/ where?: AWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of AS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for AS. + **/ cursor?: AWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` AS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` AS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of AS. + **/ distinct?: Enumerable } @@ -7198,18 +8171,26 @@ export namespace Prisma { **/ where?: AWhereInput /** - * Determine the order of the AS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of AS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing AS. **/ cursor?: AWhereUniqueInput /** - * The number of AS to fetch. If negative number, it will take AS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` AS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` AS. **/ skip?: number @@ -7411,15 +8392,63 @@ export namespace Prisma { } export type AggregateBArgs = { + /** + * Filter which B to aggregate. + **/ where?: BWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of BS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: BWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` BS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` BS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned BS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ avg?: BAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ sum?: BSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: BMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: BMaxAggregateInputType } @@ -7661,18 +8690,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__BClient | null>> /** - * Count - */ + * Count the number of Bs. + * @param {FindManyBArgs} args - Arguments to filter Bs to count. + * @example + * // Count the number of Bs + * const count = await prisma.b.count({ + * where: { + * // ... the filter for the Bs we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a B. + * @param {AggregateBArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -7751,10 +8808,35 @@ export namespace Prisma { * Filter, which B to fetch. **/ where?: BWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of BS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for BS. + **/ cursor?: BWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` BS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` BS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of BS. + **/ distinct?: Enumerable } @@ -7772,18 +8854,26 @@ export namespace Prisma { **/ where?: BWhereInput /** - * Determine the order of the BS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of BS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing BS. **/ cursor?: BWhereUniqueInput /** - * The number of BS to fetch. If negative number, it will take BS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` BS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` BS. **/ skip?: number @@ -7967,13 +9057,51 @@ export namespace Prisma { } export type AggregateCArgs = { + /** + * Filter which C to aggregate. + **/ where?: CWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of CS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: CWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` CS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` CS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned CS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: CMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: CMaxAggregateInputType } @@ -8213,18 +9341,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__CClient | null>> /** - * Count - */ + * Count the number of Cs. + * @param {FindManyCArgs} args - Arguments to filter Cs to count. + * @example + * // Count the number of Cs + * const count = await prisma.c.count({ + * where: { + * // ... the filter for the Cs we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a C. + * @param {AggregateCArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -8303,10 +9459,35 @@ export namespace Prisma { * Filter, which C to fetch. **/ where?: CWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of CS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for CS. + **/ cursor?: CWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` CS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` CS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of CS. + **/ distinct?: Enumerable } @@ -8324,18 +9505,26 @@ export namespace Prisma { **/ where?: CWhereInput /** - * Determine the order of the CS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of CS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing CS. **/ cursor?: CWhereUniqueInput /** - * The number of CS to fetch. If negative number, it will take CS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` CS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` CS. **/ skip?: number @@ -8513,13 +9702,51 @@ export namespace Prisma { } export type AggregateDArgs = { + /** + * Filter which D to aggregate. + **/ where?: DWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of DS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: DWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` DS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` DS. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned DS + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: DMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: DMaxAggregateInputType } @@ -8757,18 +9984,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__DClient | null>> /** - * Count - */ + * Count the number of Ds. + * @param {FindManyDArgs} args - Arguments to filter Ds to count. + * @example + * // Count the number of Ds + * const count = await prisma.d.count({ + * where: { + * // ... the filter for the Ds we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a D. + * @param {AggregateDArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -8847,10 +10102,35 @@ export namespace Prisma { * Filter, which D to fetch. **/ where?: DWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of DS to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for DS. + **/ cursor?: DWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` DS from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` DS. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of DS. + **/ distinct?: Enumerable } @@ -8868,18 +10148,26 @@ export namespace Prisma { **/ where?: DWhereInput /** - * Determine the order of the DS to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of DS to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing DS. **/ cursor?: DWhereUniqueInput /** - * The number of DS to fetch. If negative number, it will take DS before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` DS from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` DS. **/ skip?: number @@ -9045,13 +10333,51 @@ export namespace Prisma { } export type AggregateEArgs = { + /** + * Filter which E to aggregate. + **/ where?: EWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ES to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + **/ cursor?: EWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ES from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` ES. + **/ skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned ES + **/ count?: true + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ min?: EMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ max?: EMaxAggregateInputType } @@ -9285,18 +10611,46 @@ export namespace Prisma { args: Subset ): CheckSelect, Prisma__EClient | null>> /** - * Count - */ + * Count the number of Es. + * @param {FindManyEArgs} args - Arguments to filter Es to count. + * @example + * // Count the number of Es + * const count = await prisma.e.count({ + * where: { + * // ... the filter for the Es we want to count + * } + * }) + **/ count(args?: Omit): Promise + /** - * Group By - */ + * Group By + **/ groupBy(args: Subset): Promise> /** - * Aggregate - */ + * Allows you to perform aggregations operations on a E. + * @param {AggregateEArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ aggregate(args: Subset): Promise> } @@ -9375,10 +10729,35 @@ export namespace Prisma { * Filter, which E to fetch. **/ where?: EWhereInput + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ES to fetch. + **/ orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for ES. + **/ cursor?: EWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ES from the position of the cursor. + **/ take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first \`n\` ES. + **/ skip?: number + /** + * @link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs + * + * Filter by unique combinations of ES. + **/ distinct?: Enumerable } @@ -9396,18 +10775,26 @@ export namespace Prisma { **/ where?: EWhereInput /** - * Determine the order of the ES to fetch. + * @link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs + * + * Determine the order of ES to fetch. **/ orderBy?: Enumerable /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * * Sets the position for listing ES. **/ cursor?: EWhereUniqueInput /** - * The number of ES to fetch. If negative number, it will take ES before the \`cursor\`. + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take \`±n\` ES from the position of the cursor. **/ take?: number /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * * Skip the first \`n\` ES. **/ skip?: number diff --git a/src/packages/client/src/generation/TSClient/Args.ts b/src/packages/client/src/generation/TSClient/Args.ts index 4351c84886d2..94bc8482667b 100644 --- a/src/packages/client/src/generation/TSClient/Args.ts +++ b/src/packages/client/src/generation/TSClient/Args.ts @@ -1,8 +1,7 @@ import indent from 'indent-string' import { Generatable } from './Generatable' import { DMMF } from '../../runtime/dmmf-types' -import { ExportCollector, topLevelArgsJsDocs } from './helpers' -import pluralize from 'pluralize' +import { ExportCollector, getArgFieldJSDoc } from './helpers' import { getIncludeName, getModelArgName, getSelectName } from '../utils' import { InputField } from './Input' import { TAB_SIZE } from './constants' @@ -18,18 +17,8 @@ export class ArgsType implements Generatable { const { action, args } = this const { name } = this.model - const singular = name - const plural = pluralize(name) - for (const arg of args) { - if ( - action && - topLevelArgsJsDocs[action] && - topLevelArgsJsDocs[action][arg.name] - ) { - const comment = topLevelArgsJsDocs[action][arg.name](singular, plural) - arg.comment = comment - } + arg.comment = getArgFieldJSDoc(this.model, action, arg) } const selectName = getSelectName(name) diff --git a/src/packages/client/src/generation/TSClient/Input.ts b/src/packages/client/src/generation/TSClient/Input.ts index 7f87f3a2a0f0..cd5c4ded5b02 100644 --- a/src/packages/client/src/generation/TSClient/Input.ts +++ b/src/packages/client/src/generation/TSClient/Input.ts @@ -1,9 +1,9 @@ import indent from 'indent-string' import { DMMF } from '../../runtime/dmmf-types' import { + argIsInputType, GraphQLScalarToJSTypeTable, JSOutputTypeToInputType, - argIsInputType, } from '../../runtime/utils/common' import { uniqueBy } from '../../runtime/utils/uniqueBy' import { TAB_SIZE } from './constants' diff --git a/src/packages/client/src/generation/TSClient/Model.ts b/src/packages/client/src/generation/TSClient/Model.ts index 4d4547885196..09e732ba35fb 100644 --- a/src/packages/client/src/generation/TSClient/Model.ts +++ b/src/packages/client/src/generation/TSClient/Model.ts @@ -26,7 +26,7 @@ import { } from '../utils' import { ArgsType, MinimalArgsType } from './Args' import { Generatable, TS } from './Generatable' -import { ExportCollector, getMethodJSDoc } from './helpers' +import { ExportCollector, getArgFieldJSDoc, getArgs, getGenericMethod, getMethodJSDoc, wrapComment } from './helpers' import { InputType } from './Input' import { ModelOutputField, OutputType } from './Output' import { SchemaOutputType } from './SchemaOutput' @@ -76,7 +76,7 @@ export class Model implements Generatable { this.collector, ), ) - } else if (action !== 'groupBy') { + } else if (action !== 'groupBy' && action !== 'aggregate') { argsTypes.push( new ArgsType( field.args, @@ -115,7 +115,10 @@ export class Model implements Generatable { export type ${groupByArgsName} = { ${indent( groupByRootField.args - .map((arg) => new InputField(arg, false, arg.name === 'by').toTS()) + .map((arg) => { + arg.comment = getArgFieldJSDoc(model, DMMF.ModelAction.groupBy, arg) + return new InputField(arg, false, arg.name === 'by').toTS() + }) .concat( groupByType.fields .filter((f) => f.outputType.location === 'outputObjectTypes') @@ -252,15 +255,23 @@ ${ export type ${aggregateArgsName} = { ${indent( aggregateRootField.args - .map((arg) => new InputField(arg).toTS()) + .map((arg) => { + arg.comment = getArgFieldJSDoc(model, DMMF.ModelAction.aggregate, arg) + return new InputField(arg).toTS() + }) .concat( aggregateType.fields.map((f) => { + let data = '' + const comment = getArgFieldJSDoc(model, DMMF.ModelAction.aggregate, f.name) + data += comment ? wrapComment(comment) + '\n' : '' if (f.name === 'count') { - return `${f.name}?: true` - } - return `${f.name}?: ${getAggregateInputType( - (f.outputType.type as DMMF.OutputType).name, - )}` + data +=`${f.name}?: true` + } else { + data +=`${f.name}?: ${getAggregateInputType( + (f.outputType.type as DMMF.OutputType).name, + )}` + } + return data }), ) .join('\n'), @@ -395,8 +406,6 @@ export class ModelDelegate implements Generatable { ) const previewFeatures = this.generator?.previewFeatures ?? [] const groupByEnabled = previewFeatures.includes('groupBy') - - // TODO: The following code needs to be split up and is a mess return `\ export interface ${name}Delegate { ${indent( @@ -404,22 +413,14 @@ ${indent( .map( ([actionName]: [any, any]): string => `${getMethodJSDoc(actionName, mapping, model)} -${actionName}( - args${ - actionName === DMMF.ModelAction.findMany || - actionName === DMMF.ModelAction.findFirst || - actionName === DMMF.ModelAction.deleteMany - ? '?' - : '' - }: Subset +${actionName}${getGenericMethod(name, actionName)}( + ${getArgs(name, actionName)} ): ${getSelectReturnType({ name, actionName, projection: Projection.select })}`, ) .join('\n'), TAB_SIZE, )} - /** - * Count - */ + ${getMethodJSDoc(DMMF.ModelAction.count, mapping, model)} count(args?: Omit<${getModelArgName( name, DMMF.ModelAction.findMany, @@ -427,9 +428,8 @@ ${actionName}( ${ groupByEnabled - ? `/** - * Group By - */ + ? ` + ${getMethodJSDoc(DMMF.ModelAction.groupBy, mapping, model)} groupBy(args: Subset( : `` } - /** - * Aggregate - */ + ${getMethodJSDoc(DMMF.ModelAction.aggregate, mapping, model)} aggregate(args: Subset string + fields: { + [field: string]: (singular: string, plural: string) => string + } + } +} +function addLinkToDocs(comment: string, docs: keyof typeof Docs) { + return `${Docs[docs]} + +${comment}` +} +const JSDocFields = { + take: (singular, plural) => + addLinkToDocs( + `Take \`±n\` ${plural} from the position of the cursor.`, + 'pagination', + ), + skip: (singular, plural) => + addLinkToDocs(`Skip the first \`n\` ${plural}.`, 'pagination'), + count: (singular, plural) => + addLinkToDocs(`Count returned ${plural}`, 'aggregations'), + avg: (singular, plural) => + addLinkToDocs(`Select which fields to average`, 'aggregations'), + sum: (singular, plural) => + addLinkToDocs(`Select which fields to sum`, 'aggregations'), + min: (singular, plural) => + addLinkToDocs( + `Select which fields to find the minimum value`, + 'aggregations', + ), + max: (singular, plural) => + addLinkToDocs( + `Select which fields to find the maximum value`, + 'aggregations', + ), + distinct: (singular, plural) => + addLinkToDocs(`Filter by unique combinations of ${plural}.`, 'distinct'), + orderBy: (singular, plural) => + addLinkToDocs(`Determine the order of ${plural} to fetch.`, 'sorting'), +} +export const JSDocs: JSDocsType = { + groupBy: { + body: (ctx) => `Group By`, + fields: {}, + }, + create: { + body: (ctx) => `Create a ${ctx.singular}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to create a ${ctx.singular}. +@example +// Create one ${ctx.singular} +const ${ctx.singular} = await ${ctx.method}({ + data: { + // ... data to create a ${ctx.singular} + } +}) +`, + fields: { + data: (singular, plural) => `The data needed to create a ${singular}.`, + }, + }, + findOne: { + body: (ctx) => + `Find zero or one ${ctx.singular} that matches the filter. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to find a ${ctx.singular} +@deprecated This will be deprecated please use ${`prisma.${lowerCase( + ctx.mapping.model, + )}.findUnique`} +@example +// Get one ${ctx.singular} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + where: { + // ... provide filter here + } +})`, + fields: { + where: (singular, plural) => `Filter, which ${singular} to fetch.`, + }, + }, + findUnique: { + body: (ctx) => + `Find zero or one ${ctx.singular} that matches the filter. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to find a ${ctx.singular} +@example +// Get one ${ctx.singular} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + where: { + // ... provide filter here + } +})`, + fields: { + where: (singular, plural) => `Filter, which ${singular} to fetch.`, + }, + }, + findFirst: { + body: (ctx) => + `Find the first ${ctx.singular} that matches the filter. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to find a ${ctx.singular} +@example +// Get one ${ctx.singular} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + where: { + // ... provide filter here + } +})`, + fields: { + where: (singular, plural) => `Filter, which ${singular} to fetch.`, + orderBy: JSDocFields.orderBy, + cursor: (singular, plural) => + addLinkToDocs( + `Sets the position for searching for ${plural}.`, + 'cursor', + ), + take: JSDocFields.take, + skip: JSDocFields.skip, + distinct: JSDocFields.distinct, + }, + }, + findMany: { + body: (ctx) => { + const onlySelect = ctx.firstScalar + ? `\n// Only select the \`${ctx.firstScalar.name}\` +const ${lowerCase(ctx.mapping.model)}With${capitalize( + ctx.firstScalar.name, + )}Only = await ${ctx.method}({ select: { ${ + ctx.firstScalar.name + }: true } })` + : '' + + return `Find zero or more ${ctx.plural} that matches the filter. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}=} args - Arguments to filter and select certain fields only. +@example +// Get all ${ctx.plural} +const ${ctx.mapping.plural} = await ${ctx.method}() + +// Get first 10 ${ctx.plural} +const ${ctx.mapping.plural} = await ${ctx.method}({ take: 10 }) +${onlySelect} +` + }, + fields: { + where: (singular, plural) => `Filter, which ${plural} to fetch.`, + orderBy: JSDocFields.orderBy, + skip: JSDocFields.skip, + cursor: (singular, plural) => + addLinkToDocs(`Sets the position for listing ${plural}.`, 'cursor'), + take: JSDocFields.take, + }, + }, + update: { + body: (ctx) => + `Update one ${ctx.singular}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to update one ${ctx.singular}. +@example +// Update one ${ctx.singular} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + where: { + // ... provide filter here + }, + data: { + // ... provide data here + } +}) +`, + fields: { + data: (singular, plural) => `The data needed to update a ${singular}.`, + where: (singular, plural) => `Choose, which ${singular} to update.`, + }, + }, + upsert: { + body: (ctx) => + `Create or update one ${ctx.singular}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to update or create a ${ctx.singular}. +@example +// Update or create a ${ctx.singular} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + create: { + // ... data to create a ${ctx.singular} + }, + update: { + // ... in case it already exists, update + }, + where: { + // ... the filter for the ${ctx.singular} we want to update + } +})`, + fields: { + where: (singular, plural) => + `The filter to search for the ${singular} to update in case it exists.`, + create: (singular, plural) => + `In case the ${singular} found by the \`where\` argument doesn't exist, create a new ${singular} with this data.`, + update: (singular, plural) => + `In case the ${singular} was found with the provided \`where\` argument, update it with this data.`, + }, + }, + delete: { + body: (ctx) => + `Delete a ${ctx.singular}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to delete one ${ctx.singular}. +@example +// Delete one ${ctx.singular} +const ${ctx.singular} = await ${ctx.method}({ + where: { + // ... filter to delete one ${ctx.singular} + } +}) +`, + fields: { + where: (singular, plural) => `Filter which ${singular} to delete.`, + }, + }, + aggregate: { + body: (ctx) => + `Allows you to perform aggregations operations on a ${ctx.singular}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Select which aggregations you would like to apply and on what fields. +@example +// Ordered by age ascending +// Where email contains prisma.io +// Limited to the 10 users +const aggregations = await prisma.user.aggregate({ + avg: { + age: true, + }, + where: { + email: { + contains: "prisma.io", + }, + }, + orderBy: { + age: "asc", + }, + take: 10, +})`, + fields: { + where: (singular, plural) => `Filter which ${singular} to aggregate.`, + orderBy: JSDocFields.orderBy, + cursor: (singular, plural) => + addLinkToDocs(`Sets the start position`, 'cursor'), + take: JSDocFields.take, + skip: JSDocFields.skip, + count: JSDocFields.count, + avg: JSDocFields.avg, + sum: JSDocFields.sum, + min: JSDocFields.min, + max: JSDocFields.max, + }, + }, + count: { + body: (ctx) => + `Count the number of ${ctx.plural}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to filter ${ctx.plural} to count. +@example +// Count the number of ${ctx.plural} +const count = await ${ctx.method}({ + where: { + // ... the filter for the ${ctx.plural} we want to count + } +})`, + fields: {}, + }, + updateMany: { + body: (ctx) => + `Update zero or more ${ctx.plural}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to update one or more rows. +@example +// Update many ${ctx.plural} +const ${lowerCase(ctx.mapping.model)} = await ${ctx.method}({ + where: { + // ... provide filter here + }, + data: { + // ... provide data here + } +}) +`, + fields: { + data: (singular, plural) => `The data used to update ${plural}.`, + where: (singular, plural) => `Filter which ${plural} to update`, + }, + }, + deleteMany: { + body: (ctx) => + `Delete zero or more ${ctx.plural}. +@param {${getModelArgName( + ctx.model.name, + ctx.action, + )}} args - Arguments to filter ${ctx.plural} to delete. +@example +// Delete a few ${ctx.plural} +const { count } = await ${ctx.method}({ + where: { + // ... provide filter here + } +}) +`, + fields: { + where: (singular, plural) => `Filter which ${plural} to delete`, + }, + }, +} diff --git a/src/packages/client/src/generation/TSClient/helpers.ts b/src/packages/client/src/generation/TSClient/helpers.ts index b0dd7410ca3a..dfccd8c7621e 100644 --- a/src/packages/client/src/generation/TSClient/helpers.ts +++ b/src/packages/client/src/generation/TSClient/helpers.ts @@ -1,184 +1,26 @@ +import pluralize from 'pluralize' import { DMMF } from '../../runtime/dmmf-types' import { capitalize, lowerCase } from '../../runtime/utils/common' -import { getModelArgName, unique } from '../utils' +import { getAggregateArgsName, getModelArgName, unique } from '../utils' +import { JSDocMethodBodyCtx, JSDocs } from './constants' export function getMethodJSDocBody( action: DMMF.ModelAction | 'findOne', mapping: DMMF.ModelMapping, model: DMMF.Model, ): string { - const singular = capitalize(mapping.model) - const plural = capitalize(mapping.plural) - const firstScalar = model.fields.find((f) => f.kind === 'scalar') - const method = `prisma.${lowerCase(mapping.model)}.${action}` - - switch (action) { - case DMMF.ModelAction.create: - return `Create a ${singular}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to create a ${singular}. -@example -// Create one ${singular} -const ${singular} = await ${method}({ - data: { - // ... data to create a ${singular} - } -}) -` - case DMMF.ModelAction.delete: - return `Delete a ${singular}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to delete one ${singular}. -@example -// Delete one ${singular} -const ${singular} = await ${method}({ - where: { - // ... filter to delete one ${singular} - } -}) -` - case DMMF.ModelAction.deleteMany: - return `Delete zero or more ${plural}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to filter ${plural} to delete. -@example -// Delete a few ${plural} -const { count } = await ${method}({ - where: { - // ... provide filter here - } -}) -` - case DMMF.ModelAction.findMany: { - const onlySelect = firstScalar - ? `\n// Only select the \`${firstScalar.name}\` -const ${lowerCase(mapping.model)}With${capitalize( - firstScalar.name, - )}Only = await ${method}({ select: { ${firstScalar.name}: true } })` - : '' - - return `Find zero or more ${plural} that matches the filter. -@param {${getModelArgName( - model.name, - action, - )}=} args - Arguments to filter and select certain fields only. -@example -// Get all ${plural} -const ${mapping.plural} = await ${method}() - -// Get first 10 ${plural} -const ${mapping.plural} = await ${method}({ take: 10 }) -${onlySelect} -` - } - case DMMF.ModelAction.findUnique: { - return `Find zero or one ${singular} that matches the filter. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to find a ${singular} -@example -// Get one ${singular} -const ${lowerCase(mapping.model)} = await ${method}({ - where: { - // ... provide filter here - } -})` - } - case 'findOne': { - return `Find zero or one ${singular} that matches the filter. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to find a ${singular} -@deprecated This will be deprecated please use ${`prisma.${lowerCase( - mapping.model, - )}.findUnique`} -@example -// Get one ${singular} -const ${lowerCase(mapping.model)} = await ${method}({ - where: { - // ... provide filter here - } -})` - } - case DMMF.ModelAction.findFirst: { - return `Find the first ${singular} that matches the filter. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to find a ${singular} -@example -// Get one ${singular} -const ${lowerCase(mapping.model)} = await ${method}({ - where: { - // ... provide filter here - } -})` - } - case DMMF.ModelAction.update: - return `Update one ${singular}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to update one ${singular}. -@example -// Update one ${singular} -const ${lowerCase(mapping.model)} = await ${method}({ - where: { - // ... provide filter here - }, - data: { - // ... provide data here - } -}) -` - - case DMMF.ModelAction.updateMany: - return `Update zero or more ${plural}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to update one or more rows. -@example -// Update many ${plural} -const ${lowerCase(mapping.model)} = await ${method}({ - where: { - // ... provide filter here - }, - data: { - // ... provide data here - } -}) -` - case DMMF.ModelAction.upsert: - return `Create or update one ${singular}. -@param {${getModelArgName( - model.name, - action, - )}} args - Arguments to update or create a ${singular}. -@example -// Update or create a ${singular} -const ${lowerCase(mapping.model)} = await ${method}({ - create: { - // ... data to create a ${singular} - }, - update: { - // ... in case it already exists, update - }, - where: { - // ... the filter for the ${singular} we want to update - } -})` + const ctx: JSDocMethodBodyCtx = { + singular: capitalize(mapping.model), + plural: capitalize(mapping.plural), + firstScalar: model.fields.find((f) => f.kind === 'scalar'), + method: `prisma.${lowerCase(mapping.model)}.${action}`, + action, + mapping, + model, } + const jsdoc = JSDocs[action]?.body(ctx) - return '' + return jsdoc ? jsdoc : '' } export function getMethodJSDoc( @@ -188,61 +30,53 @@ export function getMethodJSDoc( ): string { return wrapComment(getMethodJSDocBody(action, mapping, model)) } - +export function getGenericMethod(name: string, actionName: DMMF.ModelAction) { + if (actionName === 'count') { + return '' + } + if (actionName === 'aggregate') { + return `` + } + return `` +} +export function getArgs(name: string, actionName: DMMF.ModelAction) { + if (actionName === 'count') { + return `args?: Omit<${getModelArgName( + name, + DMMF.ModelAction.findMany, + )}, 'select' | 'include'>` + } + if (actionName === 'aggregate') { + return `args: Subset` + } + return `args${ + actionName === DMMF.ModelAction.findMany || + actionName === DMMF.ModelAction.findFirst || + actionName === DMMF.ModelAction.deleteMany + ? '?' + : '' + }: Subset` +} export function wrapComment(str: string): string { return `/**\n${str .split('\n') .map((l) => ' * ' + l) .join('\n')}\n**/` } - -/* eslint-disable @typescript-eslint/no-unused-vars */ -export const topLevelArgsJsDocs = { - findOne: { - where: (singular, plural): string => `Filter, which ${singular} to fetch.`, - }, - findUnique: { - where: (singular, plural): string => `Filter, which ${singular} to fetch.`, - }, - findFirst: { - where: (singular, plural): string => `Filter, which ${singular} to fetch.`, - }, - findMany: { - where: (singular, plural): string => `Filter, which ${plural} to fetch.`, - orderBy: (singular, plural): string => - `Determine the order of the ${plural} to fetch.`, - skip: (singular, plural): string => `Skip the first \`n\` ${plural}.`, - cursor: (singular, plural): string => - `Sets the position for listing ${plural}.`, - take: (singular, plural): string => - `The number of ${plural} to fetch. If negative number, it will take ${plural} before the \`cursor\`.`, - }, - create: { - data: (singular, plural): string => - `The data needed to create a ${singular}.`, - }, - update: { - data: (singular, plural): string => - `The data needed to update a ${singular}.`, - where: (singular, plural): string => `Choose, which ${singular} to update.`, - }, - upsert: { - where: (singular, plural): string => - `The filter to search for the ${singular} to update in case it exists.`, - create: (singular, plural): string => - `In case the ${singular} found by the \`where\` argument doesn't exist, create a new ${singular} with this data.`, - update: (singular, plural): string => - `In case the ${singular} was found with the provided \`where\` argument, update it with this data.`, - }, - delete: { - where: (singular, plural): string => `Filter which ${singular} to delete.`, - }, - aggregate: { - where: (singular, plural): string => - `Filter which ${singular} to group by.`, - }, +export function getArgFieldJSDoc( + model?: DMMF.Model, + action?: DMMF.ModelAction, + field?: DMMF.SchemaArg | string, +): string | undefined { + if (!field || !action || !model) return + const fieldName = typeof field === 'string' ? field : field.name + if (JSDocs[action] && JSDocs[action]?.fields[fieldName]) { + const singular = model.name + const plural = pluralize(model.name) + const comment = JSDocs[action]?.fields[fieldName](singular, plural) + return comment as string + } } -/* eslint-enable @typescript-eslint/no-unused-vars */ export function escapeJson(str: string): string { return str diff --git a/src/packages/client/src/generation/utils.ts b/src/packages/client/src/generation/utils.ts index da6f3a084e61..1eb35940ef7a 100644 --- a/src/packages/client/src/generation/utils.ts +++ b/src/packages/client/src/generation/utils.ts @@ -131,6 +131,10 @@ export function getModelArgName( return `${modelName}DeleteManyArgs` case DMMF.ModelAction.groupBy: return `${modelName}GroupByArgs` + case DMMF.ModelAction.aggregate: + return getAggregateArgsName(modelName) + case DMMF.ModelAction.count: + return getModelArgName(modelName, DMMF.ModelAction.findMany) } } @@ -225,6 +229,12 @@ export function getSelectReturnType({ hideCondition = false, isField = false, // eslint-disable-line @typescript-eslint/no-unused-vars }: SelectReturnTypeOptions): string { + if (actionName === 'count') { + return `Promise` + } + if (actionName === 'aggregate') + return `Promise<${getAggregateGetName(name)}>` + const isList = actionName === DMMF.ModelAction.findMany if (actionName === 'deleteMany' || actionName === 'updateMany') { diff --git a/src/packages/generator-helper/src/dmmf.ts b/src/packages/generator-helper/src/dmmf.ts index 2be094c0424d..b0ce8c894a5a 100644 --- a/src/packages/generator-helper/src/dmmf.ts +++ b/src/packages/generator-helper/src/dmmf.ts @@ -183,6 +183,7 @@ export namespace DMMF { deleteMany?: string | null aggregate?: string | null groupBy?: string | null + count?: string | null } export enum ModelAction { @@ -196,5 +197,8 @@ export namespace DMMF { delete = 'delete', deleteMany = 'deleteMany', groupBy = 'groupBy', + count= 'count', + aggregate= 'aggregate' + } }