diff options
author | 2023-06-03 19:04:19 -0300 | |
---|---|---|
committer | 2023-06-03 15:04:19 -0700 | |
commit | aabb0b77cee3cc8167a65d9b1971f1a8d09b8bda (patch) | |
tree | fd2005892eddfb10754cd9613eb0414eb3032848 | |
parent | 59d7c47e3feb18e649066cc7973ba9ec1e8aca2e (diff) | |
download | bun-aabb0b77cee3cc8167a65d9b1971f1a8d09b8bda.tar.gz bun-aabb0b77cee3cc8167a65d9b1971f1a8d09b8bda.tar.zst bun-aabb0b77cee3cc8167a65d9b1971f1a8d09b8bda.zip |
[tests] prisma tests (#3197)
-rw-r--r-- | test/js/third_party/prisma/helper.ts | 53 | ||||
-rw-r--r-- | test/js/third_party/prisma/package.json | 18 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma.test.ts | 155 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma/mongodb/schema.prisma | 30 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma/postgres/schema.prisma | 30 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma/sqlite/schema.prisma | 30 | ||||
-rw-r--r-- | test/js/third_party/prisma/prisma/types.d.ts | 3481 | ||||
-rw-r--r-- | test/package.json | 4 |
8 files changed, 3800 insertions, 1 deletions
diff --git a/test/js/third_party/prisma/helper.ts b/test/js/third_party/prisma/helper.ts new file mode 100644 index 000000000..8b4462247 --- /dev/null +++ b/test/js/third_party/prisma/helper.ts @@ -0,0 +1,53 @@ +import path from "path"; +import { bunExe, bunEnv } from "harness"; +const cwd = import.meta.dir; + +export async function generateClient(type: string) { + generate(type); + + // This should run the first time on a fresh db + try { + migrate(type); + } catch (err: any) { + if (err.message.indexOf("Environment variable not found:") !== -1) throw err; + } + + return (await import(`./prisma/${type}/client`)).PrismaClient; +} +export function migrate(type: string) { + const result = Bun.spawnSync( + [ + bunExe(), + "x", + "prisma", + "migrate", + "dev", + "--name", + "init", + "--schema", + path.join(cwd, "prisma", type, "schema.prisma"), + ], + { + cwd, + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + }, + ); + if (!result.success) throw new Error(result.stderr.toString("utf8")); +} + +export function generate(type: string) { + const result = Bun.spawnSync( + [bunExe(), "prisma", "generate", "--schema", path.join(cwd, "prisma", type, "schema.prisma")], + { + cwd, + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + }, + ); + if (!result.success) throw new Error(result.stderr.toString("utf8")); +} diff --git a/test/js/third_party/prisma/package.json b/test/js/third_party/prisma/package.json new file mode 100644 index 000000000..369bd42ba --- /dev/null +++ b/test/js/third_party/prisma/package.json @@ -0,0 +1,18 @@ +{ + "name": "prisma", + "module": "index.ts", + "type": "module", + "devDependencies": { + "bun-types": "^0.6.0", + "prisma": "4.15.0" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "@prisma/client": "4.15.0" + }, + "scripts": { + "postinstall": "prisma generate --schema=./prisma/schema.prisma" + } +} diff --git a/test/js/third_party/prisma/prisma.test.ts b/test/js/third_party/prisma/prisma.test.ts new file mode 100644 index 000000000..abe6f0635 --- /dev/null +++ b/test/js/third_party/prisma/prisma.test.ts @@ -0,0 +1,155 @@ +import { test as bunTest, expect, describe } from "bun:test"; +import { generateClient } from "./helper.ts"; +import type { PrismaClient } from "./prisma/types.d.ts"; + +function* TestIDGenerator() { + let i = 0; + while (true) { + yield i++; + } +} +const test_id = TestIDGenerator(); + +["sqlite", "postgres", "mongodb"].forEach(async type => { + let Client: typeof PrismaClient; + + try { + Client = await generateClient(type); + } catch (err: any) { + console.warn(`Skipping ${type} tests, failed to generate/migrate`, err.message); + } + + async function test(label: string, callback: Function, timeout: number = 5000) { + const it = Client ? bunTest : bunTest.skip; + + it( + label, + async () => { + const prisma = new Client(); + try { + await callback(prisma, test_id.next().value); + } finally { + await prisma.$disconnect(); + } + }, + timeout, + ); + } + + describe(`prisma ${type}`, () => { + test( + "CRUD basics", + async (prisma: PrismaClient, testId: number) => { + const user = await prisma.user.create({ + data: { + testId, + name: "Test", + email: "test@oven.sh", + }, + }); + + expect(user?.name).toBe("Test"); + expect(user?.email).toBe("test@oven.sh"); + expect(user?.testId).toBe(testId); + + const users = await prisma.user.findMany({ + where: { + testId, + name: "Test", + }, + }); + + expect(users.length).toBe(1); + + const updatedUser = await prisma.user.update({ + where: { + id: user.id, + }, + data: { + name: "Test2", + }, + }); + + expect(updatedUser?.name).toBe("Test2"); + + const deletedUser = await prisma.user.delete({ where: { id: user.id } }); + + expect(deletedUser?.name).toBe("Test2"); + }, + 20000, + ); + + test( + "CRUD with relations", + async (prisma: PrismaClient, testId: number) => { + const user = await prisma.user.create({ + data: { + testId, + name: "Test", + email: "test@oven.sh", + posts: { + create: { + testId, + title: "Hello World", + }, + }, + }, + }); + + expect(user?.name).toBe("Test"); + expect(user?.email).toBe("test@oven.sh"); + expect(user?.testId).toBe(testId); + + const usersWithPosts = await prisma.user.findMany({ + include: { + posts: true, + }, + }); + + expect(usersWithPosts.length).toBe(1); + expect(usersWithPosts[0]?.posts?.length).toBe(1); + expect(usersWithPosts[0]?.posts[0]?.title).toBe("Hello World"); + + expect(async () => await prisma.user.deleteMany({ where: { testId } })).toThrow(); + + const deletedPosts = await prisma.post.deleteMany({ where: { testId } }); + + expect(deletedPosts?.count).toBe(1); + + const deletedUser = await prisma.user.deleteMany({ where: { testId } }); + + expect(deletedUser?.count).toBe(1); + }, + 20000, + ); + + test( + "Should execute multiple commands at the same time", + async (prisma: PrismaClient, testId: number) => { + const users = await Promise.all( + new Array(10).fill(0).map((_, i) => + prisma.user.create({ + data: { + testId, + name: `Test${i}`, + email: `test${i}@oven.sh`, + }, + }), + ), + ); + + expect(users.length).toBe(10); + + users.forEach((user, i) => { + expect(user?.name).toBe(`Test${i}`); + expect(user?.email).toBe(`test${i}@oven.sh`); + }); + + const deletedUser = await prisma.user.deleteMany({ where: { testId } }); + + expect(deletedUser?.count).toBe(10); + }, + 20000, + ); + }); +}); diff --git a/test/js/third_party/prisma/prisma/mongodb/schema.prisma b/test/js/third_party/prisma/prisma/mongodb/schema.prisma new file mode 100644 index 000000000..068277689 --- /dev/null +++ b/test/js/third_party/prisma/prisma/mongodb/schema.prisma @@ -0,0 +1,30 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" + output = "client" +} + +datasource db { + provider = "mongodb" + url = env("PRISMA_MONGODB_DATABASE_URL") +} + +model User { + id String @id @default(auto()) @map("_id") @db.ObjectId + testId Int + email String + name String? + posts Post[] +} + +model Post { + id String @id @default(auto()) @map("_id") @db.ObjectId + testId Int + title String + content String? + published Boolean @default(false) + author User @relation(fields: [authorId], references: [id]) + authorId String @db.ObjectId +}
\ No newline at end of file diff --git a/test/js/third_party/prisma/prisma/postgres/schema.prisma b/test/js/third_party/prisma/prisma/postgres/schema.prisma new file mode 100644 index 000000000..010fb1dfc --- /dev/null +++ b/test/js/third_party/prisma/prisma/postgres/schema.prisma @@ -0,0 +1,30 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" + output = "client" +} + +datasource db { + provider = "postgres" + url = env("PRISMA_POSTGRES_DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + testId Int + email String + name String? + posts Post[] +} + +model Post { + id Int @id @default(autoincrement()) + testId Int + title String + content String? + published Boolean @default(false) + author User @relation(fields: [authorId], references: [id]) + authorId Int +}
\ No newline at end of file diff --git a/test/js/third_party/prisma/prisma/sqlite/schema.prisma b/test/js/third_party/prisma/prisma/sqlite/schema.prisma new file mode 100644 index 000000000..1759eeaf1 --- /dev/null +++ b/test/js/third_party/prisma/prisma/sqlite/schema.prisma @@ -0,0 +1,30 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" + output = "client" +} + +datasource db { + provider = "sqlite" + url = "file:./dev.db" +} + +model User { + id Int @id @default(autoincrement()) + testId Int + email String + name String? + posts Post[] +} + +model Post { + id Int @id @default(autoincrement()) + testId Int + title String + content String? + published Boolean @default(false) + author User @relation(fields: [authorId], references: [id]) + authorId Int +}
\ No newline at end of file diff --git a/test/js/third_party/prisma/prisma/types.d.ts b/test/js/third_party/prisma/prisma/types.d.ts new file mode 100644 index 000000000..50445717f --- /dev/null +++ b/test/js/third_party/prisma/prisma/types.d.ts @@ -0,0 +1,3481 @@ +/** + * Client + **/ + +import * as runtime from "./runtime/library"; +type UnwrapPromise<P extends any> = P extends Promise<infer R> ? R : P; +type UnwrapTuple<Tuple extends readonly unknown[]> = { + [K in keyof Tuple]: K extends `${number}` + ? Tuple[K] extends Prisma.PrismaPromise<infer X> + ? X + : UnwrapPromise<Tuple[K]> + : UnwrapPromise<Tuple[K]>; +}; + +export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>; + +/** + * Model User + * + */ +export type User = { + id: number; + testId: number; + email: string; + name: string | null; +}; + +/** + * Model Post + * + */ +export type Post = { + id: number; + testId: number; + title: string; + content: string | null; + published: boolean; + authorId: number; +}; + +/** + * ## Prisma Client ʲˢ + * + * Type-safe database client for TypeScript & Node.js + * @example + * ``` + * const prisma = new PrismaClient() + * // Fetch zero or more Users + * const users = await prisma.user.findMany() + * ``` + * + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client). + */ +export class PrismaClient< + T extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions, + U = "log" extends keyof T + ? T["log"] extends Array<Prisma.LogLevel | Prisma.LogDefinition> + ? Prisma.GetEvents<T["log"]> + : never + : never, + GlobalReject extends + | Prisma.RejectOnNotFound + | Prisma.RejectPerOperation + | false + | undefined = "rejectOnNotFound" extends keyof T ? T["rejectOnNotFound"] : false, +> { + /** + * ## Prisma Client ʲˢ + * + * Type-safe database client for TypeScript & Node.js + * @example + * ``` + * const prisma = new PrismaClient() + * // Fetch zero or more Users + * const users = await prisma.user.findMany() + * ``` + * + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client). + */ + + constructor(optionsArg?: Prisma.Subset<T, Prisma.PrismaClientOptions>); + $on<V extends U | "beforeExit">( + eventType: V, + callback: ( + event: V extends "query" ? Prisma.QueryEvent : V extends "beforeExit" ? () => Promise<void> : Prisma.LogEvent, + ) => void, + ): void; + + /** + * Connect with the database + */ + $connect(): Promise<void>; + + /** + * Disconnect from the database + */ + $disconnect(): Promise<void>; + + /** + * Add a middleware + */ + $use(cb: Prisma.Middleware): void; + + /** + * Executes a prepared raw query and returns the number of affected rows. + * @example + * ``` + * const result = await prisma.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};` + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access). + */ + $executeRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<number>; + + /** + * Executes a raw query and returns the number of affected rows. + * Susceptible to SQL injections, see documentation. + * @example + * ``` + * const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com') + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access). + */ + $executeRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<number>; + + /** + * Performs a prepared raw query and returns the `SELECT` data. + * @example + * ``` + * const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};` + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access). + */ + $queryRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<T>; + + /** + * Performs a raw query and returns the `SELECT` data. + * Susceptible to SQL injections, see documentation. + * @example + * ``` + * const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com') + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/raw-database-access). + */ + $queryRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<T>; + + /** + * Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole. + * @example + * ``` + * const [george, bob, alice] = await prisma.$transaction([ + * prisma.user.create({ data: { name: 'George' } }), + * prisma.user.create({ data: { name: 'Bob' } }), + * prisma.user.create({ data: { name: 'Alice' } }), + * ]) + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions). + */ + $transaction<P extends Prisma.PrismaPromise<any>[]>( + arg: [...P], + options?: { isolationLevel?: Prisma.TransactionIsolationLevel }, + ): Promise<UnwrapTuple<P>>; + + $transaction<R>( + fn: (prisma: Omit<this, "$connect" | "$disconnect" | "$on" | "$transaction" | "$use">) => Promise<R>, + options?: { maxWait?: number; timeout?: number; isolationLevel?: Prisma.TransactionIsolationLevel }, + ): Promise<R>; + + /** + * `prisma.user`: Exposes CRUD operations for the **User** model. + * Example usage: + * ```ts + * // Fetch zero or more Users + * const users = await prisma.user.findMany() + * ``` + */ + get user(): Prisma.UserDelegate<GlobalReject>; + + /** + * `prisma.post`: Exposes CRUD operations for the **Post** model. + * Example usage: + * ```ts + * // Fetch zero or more Posts + * const posts = await prisma.post.findMany() + * ``` + */ + get post(): Prisma.PostDelegate<GlobalReject>; +} + +export namespace Prisma { + export import DMMF = runtime.DMMF; + + export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>; + + /** + * Prisma Errors + */ + export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError; + export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError; + export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError; + export import PrismaClientInitializationError = runtime.PrismaClientInitializationError; + export import PrismaClientValidationError = runtime.PrismaClientValidationError; + export import NotFoundError = runtime.NotFoundError; + + /** + * Re-export of sql-template-tag + */ + export import sql = runtime.sqltag; + export import empty = runtime.empty; + export import join = runtime.join; + export import raw = runtime.raw; + export import Sql = runtime.Sql; + + /** + * Decimal.js + */ + export import Decimal = runtime.Decimal; + + export type DecimalJsLike = runtime.DecimalJsLike; + + /** + * Metrics + */ + export type Metrics = runtime.Metrics; + export type Metric<T> = runtime.Metric<T>; + export type MetricHistogram = runtime.MetricHistogram; + export type MetricHistogramBucket = runtime.MetricHistogramBucket; + + /** + * Prisma Client JS version: 4.15.0 + * Query Engine version: 8fbc245156db7124f997f4cecdd8d1219e360944 + */ + export type PrismaVersion = { + client: string; + }; + + export const prismaVersion: PrismaVersion; + + /** + * Utility Types + */ + + /** + * From https://github.com/sindresorhus/type-fest/ + * Matches a JSON object. + * This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. + */ + export type JsonObject = { [Key in string]?: JsonValue }; + + /** + * From https://github.com/sindresorhus/type-fest/ + * Matches a JSON array. + */ + export interface JsonArray extends Array<JsonValue> {} + + /** + * From https://github.com/sindresorhus/type-fest/ + * Matches any valid JSON value. + */ + export type JsonValue = string | number | boolean | JsonObject | JsonArray | null; + + /** + * Matches a JSON object. + * Unlike `JsonObject`, this type allows undefined and read-only properties. + */ + export type InputJsonObject = { readonly [Key in string]?: InputJsonValue | null }; + + /** + * Matches a JSON array. + * Unlike `JsonArray`, readonly arrays are assignable to this type. + */ + export interface InputJsonArray extends ReadonlyArray<InputJsonValue | null> {} + + /** + * Matches any valid value that can be used as an input for operations like + * create and update as the value of a JSON field. Unlike `JsonValue`, this + * type allows read-only arrays and read-only object properties and disallows + * `null` at the top level. + * + * `null` cannot be used as the value of a JSON field because its meaning + * would be ambiguous. Use `Prisma.JsonNull` to store the JSON null value or + * `Prisma.DbNull` to clear the JSON value and set the field to the database + * NULL value instead. + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values + */ + export type InputJsonValue = string | number | boolean | InputJsonObject | InputJsonArray; + + /** + * Types of the values used to represent different kinds of `null` values when working with JSON fields. + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + namespace NullTypes { + /** + * Type of `Prisma.DbNull`. + * + * You cannot use other instances of this class. Please use the `Prisma.DbNull` value. + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + class DbNull { + private DbNull: never; + private constructor(); + } + + /** + * Type of `Prisma.JsonNull`. + * + * You cannot use other instances of this class. Please use the `Prisma.JsonNull` value. + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + class JsonNull { + private JsonNull: never; + private constructor(); + } + + /** + * Type of `Prisma.AnyNull`. + * + * You cannot use other instances of this class. Please use the `Prisma.AnyNull` value. + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + class AnyNull { + private AnyNull: never; + private constructor(); + } + } + + /** + * Helper for filtering JSON entries that have `null` on the database (empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + export const DbNull: NullTypes.DbNull; + + /** + * Helper for filtering JSON entries that have JSON `null` values (not empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + export const JsonNull: NullTypes.JsonNull; + + /** + * Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull` + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ + export const AnyNull: NullTypes.AnyNull; + + type SelectAndInclude = { + select: any; + include: any; + }; + type HasSelect = { + select: any; + }; + type HasInclude = { + include: any; + }; + type CheckSelect<T, S, U> = T extends SelectAndInclude + ? "Please either choose `select` or `include`" + : T extends HasSelect + ? U + : T extends HasInclude + ? U + : S; + + /** + * Get the type of the value, that the Promise holds. + */ + export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T; + + /** + * Get the return type of a function which returns a Promise. + */ + export type PromiseReturnType<T extends (...args: any) => Promise<any>> = PromiseType<ReturnType<T>>; + + /** + * From T, pick a set of properties whose keys are in the union K + */ + type Prisma__Pick<T, K extends keyof T> = { + [P in K]: T[P]; + }; + + export type Enumerable<T> = T | Array<T>; + + export type RequiredKeys<T> = { + [K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K; + }[keyof T]; + + export type TruthyKeys<T> = keyof { + [K in keyof T as T[K] extends false | undefined | null ? never : K]: K; + }; + + export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>; + + /** + * Subset + * @desc From `T` pick properties that exist in `U`. Simple version of Intersection + */ + export type Subset<T, U> = { + [key in keyof T]: key extends keyof U ? T[key] : never; + }; + + /** + * SelectSubset + * @desc From `T` pick properties that exist in `U`. Simple version of Intersection. + * Additionally, it validates, if both select and include are present. If the case, it errors. + */ + export type SelectSubset<T, U> = { + [key in keyof T]: key extends keyof U ? T[key] : never; + } & (T extends SelectAndInclude ? "Please either choose `select` or `include`." : {}); + + /** + * Subset + Intersection + * @desc From `T` pick properties that exist in `U` and intersect `K` + */ + export type SubsetIntersection<T, U, K> = { + [key in keyof T]: key extends keyof U ? T[key] : never; + } & K; + + type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }; + + /** + * XOR is needed to have a real mutually exclusive union type + * https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types + */ + type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T; + + /** + * Is T a Record? + */ + type IsObject<T extends any> = T extends Array<any> + ? False + : T extends Date + ? False + : T extends Uint8Array + ? False + : T extends BigInt + ? False + : T extends object + ? True + : False; + + /** + * If it's T[], return T + */ + export type UnEnumerate<T extends unknown> = T extends Array<infer U> ? U : T; + + /** + * From ts-toolbelt + */ + + type __Either<O extends object, K extends Key> = Omit<O, K> & + { + // Merge all but K + [P in K]: Prisma__Pick<O, P & keyof O>; // With K possibilities + }[K]; + + type EitherStrict<O extends object, K extends Key> = Strict<__Either<O, K>>; + + type EitherLoose<O extends object, K extends Key> = ComputeRaw<__Either<O, K>>; + + type _Either<O extends object, K extends Key, strict extends Boolean> = { + 1: EitherStrict<O, K>; + 0: EitherLoose<O, K>; + }[strict]; + + type Either<O extends object, K extends Key, strict extends Boolean = 1> = O extends unknown + ? _Either<O, K, strict> + : never; + + export type Union = any; + + type PatchUndefined<O extends object, O1 extends object> = { + [K in keyof O]: O[K] extends undefined ? At<O1, K> : O[K]; + } & {}; + + /** Helper Types for "Merge" **/ + export type IntersectOf<U extends Union> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void + ? I + : never; + + export type Overwrite<O extends object, O1 extends object> = { + [K in keyof O]: K extends keyof O1 ? O1[K] : O[K]; + } & {}; + + type _Merge<U extends object> = IntersectOf< + Overwrite< + U, + { + [K in keyof U]-?: At<U, K>; + } + > + >; + + type Key = string | number | symbol; + type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never; + type AtStrict<O extends object, K extends Key> = O[K & keyof O]; + type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never; + export type At<O extends object, K extends Key, strict extends Boolean = 1> = { + 1: AtStrict<O, K>; + 0: AtLoose<O, K>; + }[strict]; + + export type ComputeRaw<A extends any> = A extends Function + ? A + : { + [K in keyof A]: A[K]; + } & {}; + + export type OptionalFlat<O> = { + [K in keyof O]?: O[K]; + } & {}; + + type _Record<K extends keyof any, T> = { + [P in K]: T; + }; + + // cause typescript not to expand types and preserve names + type NoExpand<T> = T extends unknown ? T : never; + + // this type assumes the passed object is entirely optional + type AtLeast<O extends object, K extends string> = NoExpand< + O extends unknown + ? (K extends keyof O ? { [P in K]: O[P] } & O : O) | ({ [P in keyof O as P extends K ? K : never]-?: O[P] } & O) + : never + >; + + type _Strict<U, _U = U> = U extends unknown ? U & OptionalFlat<_Record<Exclude<Keys<_U>, keyof U>, never>> : never; + + export type Strict<U extends object> = ComputeRaw<_Strict<U>>; + /** End Helper Types for "Merge" **/ + + export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>; + + /** + A [[Boolean]] + */ + export type Boolean = True | False; + + // /** + // 1 + // */ + export type True = 1; + + /** + 0 + */ + export type False = 0; + + export type Not<B extends Boolean> = { + 0: 1; + 1: 0; + }[B]; + + export type Extends<A1 extends any, A2 extends any> = [A1] extends [never] + ? 0 // anything `never` is false + : A1 extends A2 + ? 1 + : 0; + + export type Has<U extends Union, U1 extends Union> = Not<Extends<Exclude<U1, U>, U1>>; + + export type Or<B1 extends Boolean, B2 extends Boolean> = { + 0: { + 0: 0; + 1: 1; + }; + 1: { + 0: 1; + 1: 1; + }; + }[B1][B2]; + + export type Keys<U extends Union> = U extends unknown ? keyof U : never; + + type Cast<A, B> = A extends B ? A : B; + + export const type: unique symbol; + + export function validator<V>(): <S>(select: runtime.Types.Utils.LegacyExact<S, V>) => S; + + /** + * Used by group by + */ + + export type GetScalarType<T, O> = O extends object + ? { + [P in keyof T]: P extends keyof O ? O[P] : never; + } + : never; + + type FieldPaths<T, U = Omit<T, "_avg" | "_sum" | "_count" | "_min" | "_max">> = IsObject<T> extends True ? U : T; + + type GetHavingFields<T> = { + [K in keyof T]: Or<Or<Extends<"OR", K>, Extends<"AND", K>>, Extends<"NOT", K>> extends True + ? // infer is only needed to not hit TS limit + // based on the brilliant idea of Pierre-Antoine Mills + // https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437 + T[K] extends infer TK + ? GetHavingFields<UnEnumerate<TK> extends object ? Merge<UnEnumerate<TK>> : never> + : never + : {} extends FieldPaths<T[K]> + ? never + : K; + }[keyof T]; + + /** + * Convert tuple to union + */ + type _TupleToUnion<T> = T extends (infer E)[] ? E : never; + type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>; + type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T; + + /** + * Like `Pick`, but with an array + */ + type PickArray<T, K extends Array<keyof T>> = Prisma__Pick<T, TupleToUnion<K>>; + + /** + * Exclude all keys with underscores + */ + type ExcludeUnderscoreKeys<T extends string> = T extends `_${string}` ? never : T; + + export type FieldRef<Model, FieldType> = runtime.FieldRef<Model, FieldType>; + + type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRef<Model, FieldType>; + + export const ModelName: { + User: "User"; + Post: "Post"; + }; + + export type ModelName = (typeof ModelName)[keyof typeof ModelName]; + + export type Datasources = { + db?: Datasource; + }; + + export type DefaultPrismaClient = PrismaClient; + export type RejectOnNotFound = boolean | ((error: Error) => Error); + export type RejectPerModel = { [P in ModelName]?: RejectOnNotFound }; + export type RejectPerOperation = { [P in "findUnique" | "findFirst"]?: RejectPerModel | RejectOnNotFound }; + type IsReject<T> = T extends true ? True : T extends (err: Error) => Error ? True : False; + export type HasReject< + GlobalRejectSettings extends Prisma.PrismaClientOptions["rejectOnNotFound"], + LocalRejectSettings, + Action extends PrismaAction, + Model extends ModelName, + > = LocalRejectSettings extends RejectOnNotFound + ? IsReject<LocalRejectSettings> + : GlobalRejectSettings extends RejectPerOperation + ? Action extends keyof GlobalRejectSettings + ? GlobalRejectSettings[Action] extends RejectOnNotFound + ? IsReject<GlobalRejectSettings[Action]> + : GlobalRejectSettings[Action] extends RejectPerModel + ? Model extends keyof GlobalRejectSettings[Action] + ? IsReject<GlobalRejectSettings[Action][Model]> + : False + : False + : False + : IsReject<GlobalRejectSettings>; + export type ErrorFormat = "pretty" | "colorless" | "minimal"; + + export interface PrismaClientOptions { + /** + * Configure findUnique/findFirst to throw an error if the query returns null. + * @deprecated since 4.0.0. Use `findUniqueOrThrow`/`findFirstOrThrow` methods instead. + * @example + * ``` + * // Reject on both findUnique/findFirst + * rejectOnNotFound: true + * // Reject only on findFirst with a custom error + * rejectOnNotFound: { findFirst: (err) => new Error("Custom Error")} + * // Reject on user.findUnique with a custom error + * rejectOnNotFound: { findUnique: {User: (err) => new Error("User not found")}} + * ``` + */ + rejectOnNotFound?: RejectOnNotFound | RejectPerOperation; + /** + * Overwrites the datasource url from your schema.prisma file + */ + datasources?: Datasources; + + /** + * @default "colorless" + */ + errorFormat?: ErrorFormat; + + /** + * @example + * ``` + * // Defaults to stdout + * log: ['query', 'info', 'warn', 'error'] + * + * // Emit as events + * log: [ + * { emit: 'stdout', level: 'query' }, + * { emit: 'stdout', level: 'info' }, + * { emit: 'stdout', level: 'warn' } + * { emit: 'stdout', level: 'error' } + * ] + * ``` + * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/logging#the-log-option). + */ + log?: Array<LogLevel | LogDefinition>; + } + + /* Types for Logging */ + export type LogLevel = "info" | "query" | "warn" | "error"; + export type LogDefinition = { + level: LogLevel; + emit: "stdout" | "event"; + }; + + export type GetLogType<T extends LogLevel | LogDefinition> = T extends LogDefinition + ? T["emit"] extends "event" + ? T["level"] + : never + : never; + export type GetEvents<T extends any> = T extends Array<LogLevel | LogDefinition> + ? GetLogType<T[0]> | GetLogType<T[1]> | GetLogType<T[2]> | GetLogType<T[3]> + : never; + + export type QueryEvent = { + timestamp: Date; + query: string; + params: string; + duration: number; + target: string; + }; + + export type LogEvent = { + timestamp: Date; + message: string; + target: string; + }; + /* End Types for Logging */ + + export type PrismaAction = + | "findUnique" + | "findMany" + | "findFirst" + | "create" + | "createMany" + | "update" + | "updateMany" + | "upsert" + | "delete" + | "deleteMany" + | "executeRaw" + | "queryRaw" + | "aggregate" + | "count" + | "runCommandRaw" + | "findRaw"; + + /** + * These options are being passed into the middleware as "params" + */ + export type MiddlewareParams = { + model?: ModelName; + action: PrismaAction; + args: any; + dataPath: string[]; + runInTransaction: boolean; + }; + + /** + * The `T` type makes sure, that the `return proceed` is not forgotten in the middleware implementation + */ + export type Middleware<T = any> = ( + params: MiddlewareParams, + next: (params: MiddlewareParams) => Promise<T>, + ) => Promise<T>; + + // tested in getLogLevel.test.ts + export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined; + + /** + * `PrismaClient` proxy available in interactive transactions. + */ + export type TransactionClient = Omit< + Prisma.DefaultPrismaClient, + "$connect" | "$disconnect" | "$on" | "$transaction" | "$use" + >; + + export type Datasource = { + url?: string; + }; + + /** + * Count Types + */ + + /** + * Count Type UserCountOutputType + */ + + export type UserCountOutputType = { + posts: number; + }; + + export type UserCountOutputTypeSelect = { + posts?: boolean; + }; + + export type UserCountOutputTypeGetPayload<S extends boolean | null | undefined | UserCountOutputTypeArgs> = + S extends { select: any; include: any } + ? "Please either choose `select` or `include`" + : S extends true + ? UserCountOutputType + : S extends undefined + ? never + : S extends { include: any } & UserCountOutputTypeArgs + ? UserCountOutputType + : S extends { select: any } & UserCountOutputTypeArgs + ? { + [P in TruthyKeys<S["select"]>]: P extends keyof UserCountOutputType ? UserCountOutputType[P] : never; + } + : UserCountOutputType; + + // Custom InputTypes + + /** + * UserCountOutputType without action + */ + export type UserCountOutputTypeArgs = { + /** + * Select specific fields to fetch from the UserCountOutputType + */ + select?: UserCountOutputTypeSelect | null; + }; + + /** + * Models + */ + + /** + * Model User + */ + + export type AggregateUser = { + _count: UserCountAggregateOutputType | null; + _avg: UserAvgAggregateOutputType | null; + _sum: UserSumAggregateOutputType | null; + _min: UserMinAggregateOutputType | null; + _max: UserMaxAggregateOutputType | null; + }; + + export type UserAvgAggregateOutputType = { + id: number | null; + testId: number | null; + }; + + export type UserSumAggregateOutputType = { + id: number | null; + testId: number | null; + }; + + export type UserMinAggregateOutputType = { + id: number | null; + testId: number | null; + email: string | null; + name: string | null; + }; + + export type UserMaxAggregateOutputType = { + id: number | null; + testId: number | null; + email: string | null; + name: string | null; + }; + + export type UserCountAggregateOutputType = { + id: number; + testId: number; + email: number; + name: number; + _all: number; + }; + + export type UserAvgAggregateInputType = { + id?: true; + testId?: true; + }; + + export type UserSumAggregateInputType = { + id?: true; + testId?: true; + }; + + export type UserMinAggregateInputType = { + id?: true; + testId?: true; + email?: true; + name?: true; + }; + + export type UserMaxAggregateInputType = { + id?: true; + testId?: true; + email?: true; + name?: true; + }; + + export type UserCountAggregateInputType = { + id?: true; + testId?: true; + email?: true; + name?: true; + _all?: true; + }; + + export type UserAggregateArgs = { + /** + * 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<UserOrderByWithRelationInput>; + /** + * {@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 | UserCountAggregateInputType; + /** + * {@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; + }; + + export type GetUserAggregateType<T extends UserAggregateArgs> = { + [P in keyof T & keyof AggregateUser]: P extends "_count" | "count" + ? T[P] extends true + ? number + : GetScalarType<T[P], AggregateUser[P]> + : GetScalarType<T[P], AggregateUser[P]>; + }; + + export type UserGroupByArgs = { + where?: UserWhereInput; + orderBy?: Enumerable<UserOrderByWithAggregationInput>; + by: UserScalarFieldEnum[]; + having?: UserScalarWhereWithAggregatesInput; + take?: number; + skip?: number; + _count?: UserCountAggregateInputType | true; + _avg?: UserAvgAggregateInputType; + _sum?: UserSumAggregateInputType; + _min?: UserMinAggregateInputType; + _max?: UserMaxAggregateInputType; + }; + + export type UserGroupByOutputType = { + id: number; + testId: number; + email: string; + name: string | null; + _count: UserCountAggregateOutputType | null; + _avg: UserAvgAggregateOutputType | null; + _sum: UserSumAggregateOutputType | null; + _min: UserMinAggregateOutputType | null; + _max: UserMaxAggregateOutputType | null; + }; + + type GetUserGroupByPayload<T extends UserGroupByArgs> = Prisma.PrismaPromise< + Array< + PickArray<UserGroupByOutputType, T["by"]> & { + [P in keyof T & keyof UserGroupByOutputType]: P extends "_count" + ? T[P] extends boolean + ? number + : GetScalarType<T[P], UserGroupByOutputType[P]> + : GetScalarType<T[P], UserGroupByOutputType[P]>; + } + > + >; + + export type UserSelect = { + id?: boolean; + testId?: boolean; + email?: boolean; + name?: boolean; + posts?: boolean | User$postsArgs; + _count?: boolean | UserCountOutputTypeArgs; + }; + + export type UserInclude = { + posts?: boolean | User$postsArgs; + _count?: boolean | UserCountOutputTypeArgs; + }; + + export type UserGetPayload<S extends boolean | null | undefined | UserArgs> = S extends { select: any; include: any } + ? "Please either choose `select` or `include`" + : S extends true + ? User + : S extends undefined + ? never + : S extends { include: any } & (UserArgs | UserFindManyArgs) + ? User & { + [P in TruthyKeys<S["include"]>]: P extends "posts" + ? Array<PostGetPayload<S["include"][P]>> + : P extends "_count" + ? UserCountOutputTypeGetPayload<S["include"][P]> + : never; + } + : S extends { select: any } & (UserArgs | UserFindManyArgs) + ? { + [P in TruthyKeys<S["select"]>]: P extends "posts" + ? Array<PostGetPayload<S["select"][P]>> + : P extends "_count" + ? UserCountOutputTypeGetPayload<S["select"][P]> + : P extends keyof User + ? User[P] + : never; + } + : User; + + type UserCountArgs = Omit<UserFindManyArgs, "select" | "include"> & { + select?: UserCountAggregateInputType | true; + }; + + export interface UserDelegate< + GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined, + > { + /** + * Find zero or one User that matches the filter. + * @param {UserFindUniqueArgs} args - Arguments to find a User + * @example + * // Get one User + * const user = await prisma.user.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUnique< + T extends UserFindUniqueArgs, + LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T["rejectOnNotFound"] : undefined, + >( + args: SelectSubset<T, UserFindUniqueArgs>, + ): HasReject<GlobalRejectSettings, LocalRejectSettings, "findUnique", "User"> extends True + ? Prisma__UserClient<UserGetPayload<T>> + : Prisma__UserClient<UserGetPayload<T> | null, null>; + + /** + * Find one User that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {UserFindUniqueOrThrowArgs} args - Arguments to find a User + * @example + * // Get one User + * const user = await prisma.user.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUniqueOrThrow<T extends UserFindUniqueOrThrowArgs>( + args?: SelectSubset<T, UserFindUniqueOrThrowArgs>, + ): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Find the first User that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserFindFirstArgs} args - Arguments to find a User + * @example + * // Get one User + * const user = await prisma.user.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirst< + T extends UserFindFirstArgs, + LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T["rejectOnNotFound"] : undefined, + >( + args?: SelectSubset<T, UserFindFirstArgs>, + ): HasReject<GlobalRejectSettings, LocalRejectSettings, "findFirst", "User"> extends True + ? Prisma__UserClient<UserGetPayload<T>> + : Prisma__UserClient<UserGetPayload<T> | null, null>; + + /** + * Find the first User that matches the filter or + * throw `NotFoundError` if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserFindFirstOrThrowArgs} args - Arguments to find a User + * @example + * // Get one User + * const user = await prisma.user.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirstOrThrow<T extends UserFindFirstOrThrowArgs>( + args?: SelectSubset<T, UserFindFirstOrThrowArgs>, + ): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Find zero or more Users that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserFindManyArgs=} args - Arguments to filter and select certain fields only. + * @example + * // Get all Users + * const users = await prisma.user.findMany() + * + * // Get first 10 Users + * const users = await prisma.user.findMany({ take: 10 }) + * + * // Only select the `id` + * const userWithIdOnly = await prisma.user.findMany({ select: { id: true } }) + * + **/ + findMany<T extends UserFindManyArgs>( + args?: SelectSubset<T, UserFindManyArgs>, + ): Prisma.PrismaPromise<Array<UserGetPayload<T>>>; + + /** + * Create a User. + * @param {UserCreateArgs} args - Arguments to create a User. + * @example + * // Create one User + * const User = await prisma.user.create({ + * data: { + * // ... data to create a User + * } + * }) + * + **/ + create<T extends UserCreateArgs>(args: SelectSubset<T, UserCreateArgs>): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Delete a User. + * @param {UserDeleteArgs} args - Arguments to delete one User. + * @example + * // Delete one User + * const User = await prisma.user.delete({ + * where: { + * // ... filter to delete one User + * } + * }) + * + **/ + delete<T extends UserDeleteArgs>(args: SelectSubset<T, UserDeleteArgs>): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Update one User. + * @param {UserUpdateArgs} args - Arguments to update one User. + * @example + * // Update one User + * const user = await prisma.user.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + update<T extends UserUpdateArgs>(args: SelectSubset<T, UserUpdateArgs>): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Delete zero or more Users. + * @param {UserDeleteManyArgs} args - Arguments to filter Users to delete. + * @example + * // Delete a few Users + * const { count } = await prisma.user.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + **/ + deleteMany<T extends UserDeleteManyArgs>( + args?: SelectSubset<T, UserDeleteManyArgs>, + ): Prisma.PrismaPromise<BatchPayload>; + + /** + * Update zero or more Users. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Users + * const user = await prisma.user.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + updateMany<T extends UserUpdateManyArgs>( + args: SelectSubset<T, UserUpdateManyArgs>, + ): Prisma.PrismaPromise<BatchPayload>; + + /** + * Create or update one User. + * @param {UserUpsertArgs} args - Arguments to update or create a User. + * @example + * // Update or create a User + * const user = await prisma.user.upsert({ + * create: { + * // ... data to create a User + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the User we want to update + * } + * }) + **/ + upsert<T extends UserUpsertArgs>(args: SelectSubset<T, UserUpsertArgs>): Prisma__UserClient<UserGetPayload<T>>; + + /** + * Count the number of Users. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserCountArgs} 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<T extends UserCountArgs>( + args?: Subset<T, UserCountArgs>, + ): Prisma.PrismaPromise< + T extends _Record<"select", any> + ? T["select"] extends true + ? number + : GetScalarType<T["select"], UserCountAggregateOutputType> + : number + >; + + /** + * Allows you to perform aggregations operations on a User. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserAggregateArgs} 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<T extends UserAggregateArgs>( + args: Subset<T, UserAggregateArgs>, + ): Prisma.PrismaPromise<GetUserAggregateType<T>>; + + /** + * Group by User. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {UserGroupByArgs} 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 + * }, + * }) + * + **/ + groupBy< + T extends UserGroupByArgs, + HasSelectOrTake extends Or<Extends<"skip", Keys<T>>, Extends<"take", Keys<T>>>, + OrderByArg extends True extends HasSelectOrTake + ? { orderBy: UserGroupByArgs["orderBy"] } + : { orderBy?: UserGroupByArgs["orderBy"] }, + OrderFields extends ExcludeUnderscoreKeys<Keys<MaybeTupleToUnion<T["orderBy"]>>>, + ByFields extends TupleToUnion<T["by"]>, + ByValid extends Has<ByFields, OrderFields>, + HavingFields extends GetHavingFields<T["having"]>, + HavingValid extends Has<ByFields, HavingFields>, + ByEmpty extends T["by"] extends never[] ? True : False, + InputErrors extends ByEmpty extends True + ? `Error: "by" must not be empty.` + : HavingValid extends False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [Error, "Field ", P, ` in "having" needs to be provided in "by"`]; + }[HavingFields] + : "take" extends Keys<T> + ? "orderBy" extends Keys<T> + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : "skip" extends Keys<T> + ? "orderBy" extends Keys<T> + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields], + >( + args: SubsetIntersection<T, UserGroupByArgs, OrderByArg> & InputErrors, + ): {} extends InputErrors ? GetUserGroupByPayload<T> : Prisma.PrismaPromise<InputErrors>; + } + + /** + * The delegate class that acts as a "Promise-like" for User. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ + export class Prisma__UserClient<T, Null = never> implements Prisma.PrismaPromise<T> { + private readonly _dmmf; + private readonly _queryType; + private readonly _rootField; + private readonly _clientMethod; + private readonly _args; + private readonly _dataPath; + private readonly _errorFormat; + private readonly _measurePerformance?; + private _isList; + private _callsite; + private _requestPromise?; + readonly [Symbol.toStringTag]: "PrismaPromise"; + constructor( + _dmmf: runtime.DMMFClass, + _queryType: "query" | "mutation", + _rootField: string, + _clientMethod: string, + _args: any, + _dataPath: string[], + _errorFormat: ErrorFormat, + _measurePerformance?: boolean | undefined, + _isList?: boolean, + ); + + posts<T extends User$postsArgs = {}>( + args?: Subset<T, User$postsArgs>, + ): Prisma.PrismaPromise<Array<PostGetPayload<T>> | Null>; + + private get _document(); + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then<TResult1 = T, TResult2 = never>( + onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null, + ): Promise<TResult1 | TResult2>; + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch<TResult = never>( + onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null, + ): Promise<T | TResult>; + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): Promise<T>; + } + + // Custom InputTypes + + /** + * User base type for findUnique actions + */ + export type UserFindUniqueArgsBase = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * Filter, which User to fetch. + */ + where: UserWhereUniqueInput; + }; + + /** + * User findUnique + */ + export interface UserFindUniqueArgs extends UserFindUniqueArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findUniqueOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound; + } + + /** + * User findUniqueOrThrow + */ + export type UserFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * Filter, which User to fetch. + */ + where: UserWhereUniqueInput; + }; + + /** + * User base type for findFirst actions + */ + export type UserFindFirstArgsBase = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * 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<UserOrderByWithRelationInput>; + /** + * {@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<UserScalarFieldEnum>; + }; + + /** + * User findFirst + */ + export interface UserFindFirstArgs extends UserFindFirstArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findFirstOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound; + } + + /** + * User findFirstOrThrow + */ + export type UserFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * 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<UserOrderByWithRelationInput>; + /** + * {@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<UserScalarFieldEnum>; + }; + + /** + * User findMany + */ + export type UserFindManyArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * Filter, which Users 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<UserOrderByWithRelationInput>; + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing 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; + distinct?: Enumerable<UserScalarFieldEnum>; + }; + + /** + * User create + */ + export type UserCreateArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * The data needed to create a User. + */ + data: XOR<UserCreateInput, UserUncheckedCreateInput>; + }; + + /** + * User update + */ + export type UserUpdateArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * The data needed to update a User. + */ + data: XOR<UserUpdateInput, UserUncheckedUpdateInput>; + /** + * Choose, which User to update. + */ + where: UserWhereUniqueInput; + }; + + /** + * User updateMany + */ + export type UserUpdateManyArgs = { + /** + * The data used to update Users. + */ + data: XOR<UserUpdateManyMutationInput, UserUncheckedUpdateManyInput>; + /** + * Filter which Users to update + */ + where?: UserWhereInput; + }; + + /** + * User upsert + */ + export type UserUpsertArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * The filter to search for the User to update in case it exists. + */ + where: UserWhereUniqueInput; + /** + * In case the User found by the `where` argument doesn't exist, create a new User with this data. + */ + create: XOR<UserCreateInput, UserUncheckedCreateInput>; + /** + * In case the User was found with the provided `where` argument, update it with this data. + */ + update: XOR<UserUpdateInput, UserUncheckedUpdateInput>; + }; + + /** + * User delete + */ + export type UserDeleteArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + /** + * Filter which User to delete. + */ + where: UserWhereUniqueInput; + }; + + /** + * User deleteMany + */ + export type UserDeleteManyArgs = { + /** + * Filter which Users to delete + */ + where?: UserWhereInput; + }; + + /** + * User.posts + */ + export type User$postsArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + where?: PostWhereInput; + orderBy?: Enumerable<PostOrderByWithRelationInput>; + cursor?: PostWhereUniqueInput; + take?: number; + skip?: number; + distinct?: Enumerable<PostScalarFieldEnum>; + }; + + /** + * User without action + */ + export type UserArgs = { + /** + * Select specific fields to fetch from the User + */ + select?: UserSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: UserInclude | null; + }; + + /** + * Model Post + */ + + export type AggregatePost = { + _count: PostCountAggregateOutputType | null; + _avg: PostAvgAggregateOutputType | null; + _sum: PostSumAggregateOutputType | null; + _min: PostMinAggregateOutputType | null; + _max: PostMaxAggregateOutputType | null; + }; + + export type PostAvgAggregateOutputType = { + id: number | null; + testId: number | null; + authorId: number | null; + }; + + export type PostSumAggregateOutputType = { + id: number | null; + testId: number | null; + authorId: number | null; + }; + + export type PostMinAggregateOutputType = { + id: number | null; + testId: number | null; + title: string | null; + content: string | null; + published: boolean | null; + authorId: number | null; + }; + + export type PostMaxAggregateOutputType = { + id: number | null; + testId: number | null; + title: string | null; + content: string | null; + published: boolean | null; + authorId: number | null; + }; + + export type PostCountAggregateOutputType = { + id: number; + testId: number; + title: number; + content: number; + published: number; + authorId: number; + _all: number; + }; + + export type PostAvgAggregateInputType = { + id?: true; + testId?: true; + authorId?: true; + }; + + export type PostSumAggregateInputType = { + id?: true; + testId?: true; + authorId?: true; + }; + + export type PostMinAggregateInputType = { + id?: true; + testId?: true; + title?: true; + content?: true; + published?: true; + authorId?: true; + }; + + export type PostMaxAggregateInputType = { + id?: true; + testId?: true; + title?: true; + content?: true; + published?: true; + authorId?: true; + }; + + export type PostCountAggregateInputType = { + id?: true; + testId?: true; + title?: true; + content?: true; + published?: true; + authorId?: true; + _all?: true; + }; + + export type PostAggregateArgs = { + /** + * 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<PostOrderByWithRelationInput>; + /** + * {@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 | PostCountAggregateInputType; + /** + * {@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; + }; + + export type GetPostAggregateType<T extends PostAggregateArgs> = { + [P in keyof T & keyof AggregatePost]: P extends "_count" | "count" + ? T[P] extends true + ? number + : GetScalarType<T[P], AggregatePost[P]> + : GetScalarType<T[P], AggregatePost[P]>; + }; + + export type PostGroupByArgs = { + where?: PostWhereInput; + orderBy?: Enumerable<PostOrderByWithAggregationInput>; + by: PostScalarFieldEnum[]; + having?: PostScalarWhereWithAggregatesInput; + take?: number; + skip?: number; + _count?: PostCountAggregateInputType | true; + _avg?: PostAvgAggregateInputType; + _sum?: PostSumAggregateInputType; + _min?: PostMinAggregateInputType; + _max?: PostMaxAggregateInputType; + }; + + export type PostGroupByOutputType = { + id: number; + testId: number; + title: string; + content: string | null; + published: boolean; + authorId: number; + _count: PostCountAggregateOutputType | null; + _avg: PostAvgAggregateOutputType | null; + _sum: PostSumAggregateOutputType | null; + _min: PostMinAggregateOutputType | null; + _max: PostMaxAggregateOutputType | null; + }; + + type GetPostGroupByPayload<T extends PostGroupByArgs> = Prisma.PrismaPromise< + Array< + PickArray<PostGroupByOutputType, T["by"]> & { + [P in keyof T & keyof PostGroupByOutputType]: P extends "_count" + ? T[P] extends boolean + ? number + : GetScalarType<T[P], PostGroupByOutputType[P]> + : GetScalarType<T[P], PostGroupByOutputType[P]>; + } + > + >; + + export type PostSelect = { + id?: boolean; + testId?: boolean; + title?: boolean; + content?: boolean; + published?: boolean; + authorId?: boolean; + author?: boolean | UserArgs; + }; + + export type PostInclude = { + author?: boolean | UserArgs; + }; + + export type PostGetPayload<S extends boolean | null | undefined | PostArgs> = S extends { select: any; include: any } + ? "Please either choose `select` or `include`" + : S extends true + ? Post + : S extends undefined + ? never + : S extends { include: any } & (PostArgs | PostFindManyArgs) + ? Post & { + [P in TruthyKeys<S["include"]>]: P extends "author" ? UserGetPayload<S["include"][P]> : never; + } + : S extends { select: any } & (PostArgs | PostFindManyArgs) + ? { + [P in TruthyKeys<S["select"]>]: P extends "author" + ? UserGetPayload<S["select"][P]> + : P extends keyof Post + ? Post[P] + : never; + } + : Post; + + type PostCountArgs = Omit<PostFindManyArgs, "select" | "include"> & { + select?: PostCountAggregateInputType | true; + }; + + export interface PostDelegate< + GlobalRejectSettings extends Prisma.RejectOnNotFound | Prisma.RejectPerOperation | false | undefined, + > { + /** + * Find zero or one Post that matches the filter. + * @param {PostFindUniqueArgs} args - Arguments to find a Post + * @example + * // Get one Post + * const post = await prisma.post.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUnique< + T extends PostFindUniqueArgs, + LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T["rejectOnNotFound"] : undefined, + >( + args: SelectSubset<T, PostFindUniqueArgs>, + ): HasReject<GlobalRejectSettings, LocalRejectSettings, "findUnique", "Post"> extends True + ? Prisma__PostClient<PostGetPayload<T>> + : Prisma__PostClient<PostGetPayload<T> | null, null>; + + /** + * Find one Post that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {PostFindUniqueOrThrowArgs} args - Arguments to find a Post + * @example + * // Get one Post + * const post = await prisma.post.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUniqueOrThrow<T extends PostFindUniqueOrThrowArgs>( + args?: SelectSubset<T, PostFindUniqueOrThrowArgs>, + ): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Find the first Post that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostFindFirstArgs} args - Arguments to find a Post + * @example + * // Get one Post + * const post = await prisma.post.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirst< + T extends PostFindFirstArgs, + LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T["rejectOnNotFound"] : undefined, + >( + args?: SelectSubset<T, PostFindFirstArgs>, + ): HasReject<GlobalRejectSettings, LocalRejectSettings, "findFirst", "Post"> extends True + ? Prisma__PostClient<PostGetPayload<T>> + : Prisma__PostClient<PostGetPayload<T> | null, null>; + + /** + * Find the first Post that matches the filter or + * throw `NotFoundError` if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostFindFirstOrThrowArgs} args - Arguments to find a Post + * @example + * // Get one Post + * const post = await prisma.post.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirstOrThrow<T extends PostFindFirstOrThrowArgs>( + args?: SelectSubset<T, PostFindFirstOrThrowArgs>, + ): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Find zero or more Posts that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostFindManyArgs=} args - Arguments to filter and select certain fields only. + * @example + * // Get all Posts + * const posts = await prisma.post.findMany() + * + * // Get first 10 Posts + * const posts = await prisma.post.findMany({ take: 10 }) + * + * // Only select the `id` + * const postWithIdOnly = await prisma.post.findMany({ select: { id: true } }) + * + **/ + findMany<T extends PostFindManyArgs>( + args?: SelectSubset<T, PostFindManyArgs>, + ): Prisma.PrismaPromise<Array<PostGetPayload<T>>>; + + /** + * Create a Post. + * @param {PostCreateArgs} args - Arguments to create a Post. + * @example + * // Create one Post + * const Post = await prisma.post.create({ + * data: { + * // ... data to create a Post + * } + * }) + * + **/ + create<T extends PostCreateArgs>(args: SelectSubset<T, PostCreateArgs>): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Delete a Post. + * @param {PostDeleteArgs} args - Arguments to delete one Post. + * @example + * // Delete one Post + * const Post = await prisma.post.delete({ + * where: { + * // ... filter to delete one Post + * } + * }) + * + **/ + delete<T extends PostDeleteArgs>(args: SelectSubset<T, PostDeleteArgs>): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Update one Post. + * @param {PostUpdateArgs} args - Arguments to update one Post. + * @example + * // Update one Post + * const post = await prisma.post.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + update<T extends PostUpdateArgs>(args: SelectSubset<T, PostUpdateArgs>): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Delete zero or more Posts. + * @param {PostDeleteManyArgs} args - Arguments to filter Posts to delete. + * @example + * // Delete a few Posts + * const { count } = await prisma.post.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + **/ + deleteMany<T extends PostDeleteManyArgs>( + args?: SelectSubset<T, PostDeleteManyArgs>, + ): Prisma.PrismaPromise<BatchPayload>; + + /** + * Update zero or more Posts. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Posts + * const post = await prisma.post.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + updateMany<T extends PostUpdateManyArgs>( + args: SelectSubset<T, PostUpdateManyArgs>, + ): Prisma.PrismaPromise<BatchPayload>; + + /** + * Create or update one Post. + * @param {PostUpsertArgs} args - Arguments to update or create a Post. + * @example + * // Update or create a Post + * const post = await prisma.post.upsert({ + * create: { + * // ... data to create a Post + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Post we want to update + * } + * }) + **/ + upsert<T extends PostUpsertArgs>(args: SelectSubset<T, PostUpsertArgs>): Prisma__PostClient<PostGetPayload<T>>; + + /** + * Count the number of Posts. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostCountArgs} 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<T extends PostCountArgs>( + args?: Subset<T, PostCountArgs>, + ): Prisma.PrismaPromise< + T extends _Record<"select", any> + ? T["select"] extends true + ? number + : GetScalarType<T["select"], PostCountAggregateOutputType> + : number + >; + + /** + * Allows you to perform aggregations operations on a Post. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostAggregateArgs} 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<T extends PostAggregateArgs>( + args: Subset<T, PostAggregateArgs>, + ): Prisma.PrismaPromise<GetPostAggregateType<T>>; + + /** + * Group by Post. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {PostGroupByArgs} 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 + * }, + * }) + * + **/ + groupBy< + T extends PostGroupByArgs, + HasSelectOrTake extends Or<Extends<"skip", Keys<T>>, Extends<"take", Keys<T>>>, + OrderByArg extends True extends HasSelectOrTake + ? { orderBy: PostGroupByArgs["orderBy"] } + : { orderBy?: PostGroupByArgs["orderBy"] }, + OrderFields extends ExcludeUnderscoreKeys<Keys<MaybeTupleToUnion<T["orderBy"]>>>, + ByFields extends TupleToUnion<T["by"]>, + ByValid extends Has<ByFields, OrderFields>, + HavingFields extends GetHavingFields<T["having"]>, + HavingValid extends Has<ByFields, HavingFields>, + ByEmpty extends T["by"] extends never[] ? True : False, + InputErrors extends ByEmpty extends True + ? `Error: "by" must not be empty.` + : HavingValid extends False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [Error, "Field ", P, ` in "having" needs to be provided in "by"`]; + }[HavingFields] + : "take" extends Keys<T> + ? "orderBy" extends Keys<T> + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : "skip" extends Keys<T> + ? "orderBy" extends Keys<T> + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"`; + }[OrderFields], + >( + args: SubsetIntersection<T, PostGroupByArgs, OrderByArg> & InputErrors, + ): {} extends InputErrors ? GetPostGroupByPayload<T> : Prisma.PrismaPromise<InputErrors>; + } + + /** + * The delegate class that acts as a "Promise-like" for Post. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ + export class Prisma__PostClient<T, Null = never> implements Prisma.PrismaPromise<T> { + private readonly _dmmf; + private readonly _queryType; + private readonly _rootField; + private readonly _clientMethod; + private readonly _args; + private readonly _dataPath; + private readonly _errorFormat; + private readonly _measurePerformance?; + private _isList; + private _callsite; + private _requestPromise?; + readonly [Symbol.toStringTag]: "PrismaPromise"; + constructor( + _dmmf: runtime.DMMFClass, + _queryType: "query" | "mutation", + _rootField: string, + _clientMethod: string, + _args: any, + _dataPath: string[], + _errorFormat: ErrorFormat, + _measurePerformance?: boolean | undefined, + _isList?: boolean, + ); + + author<T extends UserArgs = {}>(args?: Subset<T, UserArgs>): Prisma__UserClient<UserGetPayload<T> | Null>; + + private get _document(); + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then<TResult1 = T, TResult2 = never>( + onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null, + ): Promise<TResult1 | TResult2>; + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch<TResult = never>( + onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null, + ): Promise<T | TResult>; + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): Promise<T>; + } + + // Custom InputTypes + + /** + * Post base type for findUnique actions + */ + export type PostFindUniqueArgsBase = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * Filter, which Post to fetch. + */ + where: PostWhereUniqueInput; + }; + + /** + * Post findUnique + */ + export interface PostFindUniqueArgs extends PostFindUniqueArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findUniqueOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound; + } + + /** + * Post findUniqueOrThrow + */ + export type PostFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * Filter, which Post to fetch. + */ + where: PostWhereUniqueInput; + }; + + /** + * Post base type for findFirst actions + */ + export type PostFindFirstArgsBase = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * 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<PostOrderByWithRelationInput>; + /** + * {@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<PostScalarFieldEnum>; + }; + + /** + * Post findFirst + */ + export interface PostFindFirstArgs extends PostFindFirstArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findFirstOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound; + } + + /** + * Post findFirstOrThrow + */ + export type PostFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * 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<PostOrderByWithRelationInput>; + /** + * {@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<PostScalarFieldEnum>; + }; + + /** + * Post findMany + */ + export type PostFindManyArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * Filter, which Posts 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<PostOrderByWithRelationInput>; + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing 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; + distinct?: Enumerable<PostScalarFieldEnum>; + }; + + /** + * Post create + */ + export type PostCreateArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * The data needed to create a Post. + */ + data: XOR<PostCreateInput, PostUncheckedCreateInput>; + }; + + /** + * Post update + */ + export type PostUpdateArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * The data needed to update a Post. + */ + data: XOR<PostUpdateInput, PostUncheckedUpdateInput>; + /** + * Choose, which Post to update. + */ + where: PostWhereUniqueInput; + }; + + /** + * Post updateMany + */ + export type PostUpdateManyArgs = { + /** + * The data used to update Posts. + */ + data: XOR<PostUpdateManyMutationInput, PostUncheckedUpdateManyInput>; + /** + * Filter which Posts to update + */ + where?: PostWhereInput; + }; + + /** + * Post upsert + */ + export type PostUpsertArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * The filter to search for the Post to update in case it exists. + */ + where: PostWhereUniqueInput; + /** + * In case the Post found by the `where` argument doesn't exist, create a new Post with this data. + */ + create: XOR<PostCreateInput, PostUncheckedCreateInput>; + /** + * In case the Post was found with the provided `where` argument, update it with this data. + */ + update: XOR<PostUpdateInput, PostUncheckedUpdateInput>; + }; + + /** + * Post delete + */ + export type PostDeleteArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + /** + * Filter which Post to delete. + */ + where: PostWhereUniqueInput; + }; + + /** + * Post deleteMany + */ + export type PostDeleteManyArgs = { + /** + * Filter which Posts to delete + */ + where?: PostWhereInput; + }; + + /** + * Post without action + */ + export type PostArgs = { + /** + * Select specific fields to fetch from the Post + */ + select?: PostSelect | null; + /** + * Choose, which related nodes to fetch as well. + */ + include?: PostInclude | null; + }; + + /** + * Enums + */ + + export const PostScalarFieldEnum: { + id: "id"; + testId: "testId"; + title: "title"; + content: "content"; + published: "published"; + authorId: "authorId"; + }; + + export type PostScalarFieldEnum = (typeof PostScalarFieldEnum)[keyof typeof PostScalarFieldEnum]; + + export const SortOrder: { + asc: "asc"; + desc: "desc"; + }; + + export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]; + + export const TransactionIsolationLevel: { + Serializable: "Serializable"; + }; + + export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]; + + export const UserScalarFieldEnum: { + id: "id"; + testId: "testId"; + email: "email"; + name: "name"; + }; + + export type UserScalarFieldEnum = (typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum]; + + /** + * Deep Input Types + */ + + export type UserWhereInput = { + AND?: Enumerable<UserWhereInput>; + OR?: Enumerable<UserWhereInput>; + NOT?: Enumerable<UserWhereInput>; + id?: IntFilter | number; + testId?: IntFilter | number; + email?: StringFilter | string; + name?: StringNullableFilter | string | null; + posts?: PostListRelationFilter; + }; + + export type UserOrderByWithRelationInput = { + id?: SortOrder; + testId?: SortOrder; + email?: SortOrder; + name?: SortOrder; + posts?: PostOrderByRelationAggregateInput; + }; + + export type UserWhereUniqueInput = { + id?: number; + }; + + export type UserOrderByWithAggregationInput = { + id?: SortOrder; + testId?: SortOrder; + email?: SortOrder; + name?: SortOrder; + _count?: UserCountOrderByAggregateInput; + _avg?: UserAvgOrderByAggregateInput; + _max?: UserMaxOrderByAggregateInput; + _min?: UserMinOrderByAggregateInput; + _sum?: UserSumOrderByAggregateInput; + }; + + export type UserScalarWhereWithAggregatesInput = { + AND?: Enumerable<UserScalarWhereWithAggregatesInput>; + OR?: Enumerable<UserScalarWhereWithAggregatesInput>; + NOT?: Enumerable<UserScalarWhereWithAggregatesInput>; + id?: IntWithAggregatesFilter | number; + testId?: IntWithAggregatesFilter | number; + email?: StringWithAggregatesFilter | string; + name?: StringNullableWithAggregatesFilter | string | null; + }; + + export type PostWhereInput = { + AND?: Enumerable<PostWhereInput>; + OR?: Enumerable<PostWhereInput>; + NOT?: Enumerable<PostWhereInput>; + id?: IntFilter | number; + testId?: IntFilter | number; + title?: StringFilter | string; + content?: StringNullableFilter | string | null; + published?: BoolFilter | boolean; + authorId?: IntFilter | number; + author?: XOR<UserRelationFilter, UserWhereInput>; + }; + + export type PostOrderByWithRelationInput = { + id?: SortOrder; + testId?: SortOrder; + title?: SortOrder; + content?: SortOrder; + published?: SortOrder; + authorId?: SortOrder; + author?: UserOrderByWithRelationInput; + }; + + export type PostWhereUniqueInput = { + id?: number; + }; + + export type PostOrderByWithAggregationInput = { + id?: SortOrder; + testId?: SortOrder; + title?: SortOrder; + content?: SortOrder; + published?: SortOrder; + authorId?: SortOrder; + _count?: PostCountOrderByAggregateInput; + _avg?: PostAvgOrderByAggregateInput; + _max?: PostMaxOrderByAggregateInput; + _min?: PostMinOrderByAggregateInput; + _sum?: PostSumOrderByAggregateInput; + }; + + export type PostScalarWhereWithAggregatesInput = { + AND?: Enumerable<PostScalarWhereWithAggregatesInput>; + OR?: Enumerable<PostScalarWhereWithAggregatesInput>; + NOT?: Enumerable<PostScalarWhereWithAggregatesInput>; + id?: IntWithAggregatesFilter | number; + testId?: IntWithAggregatesFilter | number; + title?: StringWithAggregatesFilter | string; + content?: StringNullableWithAggregatesFilter | string | null; + published?: BoolWithAggregatesFilter | boolean; + authorId?: IntWithAggregatesFilter | number; + }; + + export type UserCreateInput = { + testId: number; + email: string; + name?: string | null; + posts?: PostCreateNestedManyWithoutAuthorInput; + }; + + export type UserUncheckedCreateInput = { + id?: number; + testId: number; + email: string; + name?: string | null; + posts?: PostUncheckedCreateNestedManyWithoutAuthorInput; + }; + + export type UserUpdateInput = { + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + posts?: PostUpdateManyWithoutAuthorNestedInput; + }; + + export type UserUncheckedUpdateInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + posts?: PostUncheckedUpdateManyWithoutAuthorNestedInput; + }; + + export type UserUpdateManyMutationInput = { + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + }; + + export type UserUncheckedUpdateManyInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + }; + + export type PostCreateInput = { + testId: number; + title: string; + content?: string | null; + published?: boolean; + author: UserCreateNestedOneWithoutPostsInput; + }; + + export type PostUncheckedCreateInput = { + id?: number; + testId: number; + title: string; + content?: string | null; + published?: boolean; + authorId: number; + }; + + export type PostUpdateInput = { + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + author?: UserUpdateOneRequiredWithoutPostsNestedInput; + }; + + export type PostUncheckedUpdateInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + authorId?: IntFieldUpdateOperationsInput | number; + }; + + export type PostUpdateManyMutationInput = { + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + }; + + export type PostUncheckedUpdateManyInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + authorId?: IntFieldUpdateOperationsInput | number; + }; + + export type IntFilter = { + equals?: number; + in?: Enumerable<number> | number; + notIn?: Enumerable<number> | number; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedIntFilter | number; + }; + + export type StringFilter = { + equals?: string; + in?: Enumerable<string> | string; + notIn?: Enumerable<string> | string; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringFilter | string; + }; + + export type StringNullableFilter = { + equals?: string | null; + in?: Enumerable<string> | string | null; + notIn?: Enumerable<string> | string | null; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringNullableFilter | string | null; + }; + + export type PostListRelationFilter = { + every?: PostWhereInput; + some?: PostWhereInput; + none?: PostWhereInput; + }; + + export type PostOrderByRelationAggregateInput = { + _count?: SortOrder; + }; + + export type UserCountOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + email?: SortOrder; + name?: SortOrder; + }; + + export type UserAvgOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + }; + + export type UserMaxOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + email?: SortOrder; + name?: SortOrder; + }; + + export type UserMinOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + email?: SortOrder; + name?: SortOrder; + }; + + export type UserSumOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + }; + + export type IntWithAggregatesFilter = { + equals?: number; + in?: Enumerable<number> | number; + notIn?: Enumerable<number> | number; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedIntWithAggregatesFilter | number; + _count?: NestedIntFilter; + _avg?: NestedFloatFilter; + _sum?: NestedIntFilter; + _min?: NestedIntFilter; + _max?: NestedIntFilter; + }; + + export type StringWithAggregatesFilter = { + equals?: string; + in?: Enumerable<string> | string; + notIn?: Enumerable<string> | string; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringWithAggregatesFilter | string; + _count?: NestedIntFilter; + _min?: NestedStringFilter; + _max?: NestedStringFilter; + }; + + export type StringNullableWithAggregatesFilter = { + equals?: string | null; + in?: Enumerable<string> | string | null; + notIn?: Enumerable<string> | string | null; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringNullableWithAggregatesFilter | string | null; + _count?: NestedIntNullableFilter; + _min?: NestedStringNullableFilter; + _max?: NestedStringNullableFilter; + }; + + export type BoolFilter = { + equals?: boolean; + not?: NestedBoolFilter | boolean; + }; + + export type UserRelationFilter = { + is?: UserWhereInput; + isNot?: UserWhereInput; + }; + + export type PostCountOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + title?: SortOrder; + content?: SortOrder; + published?: SortOrder; + authorId?: SortOrder; + }; + + export type PostAvgOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + authorId?: SortOrder; + }; + + export type PostMaxOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + title?: SortOrder; + content?: SortOrder; + published?: SortOrder; + authorId?: SortOrder; + }; + + export type PostMinOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + title?: SortOrder; + content?: SortOrder; + published?: SortOrder; + authorId?: SortOrder; + }; + + export type PostSumOrderByAggregateInput = { + id?: SortOrder; + testId?: SortOrder; + authorId?: SortOrder; + }; + + export type BoolWithAggregatesFilter = { + equals?: boolean; + not?: NestedBoolWithAggregatesFilter | boolean; + _count?: NestedIntFilter; + _min?: NestedBoolFilter; + _max?: NestedBoolFilter; + }; + + export type PostCreateNestedManyWithoutAuthorInput = { + create?: XOR<Enumerable<PostCreateWithoutAuthorInput>, Enumerable<PostUncheckedCreateWithoutAuthorInput>>; + connectOrCreate?: Enumerable<PostCreateOrConnectWithoutAuthorInput>; + connect?: Enumerable<PostWhereUniqueInput>; + }; + + export type PostUncheckedCreateNestedManyWithoutAuthorInput = { + create?: XOR<Enumerable<PostCreateWithoutAuthorInput>, Enumerable<PostUncheckedCreateWithoutAuthorInput>>; + connectOrCreate?: Enumerable<PostCreateOrConnectWithoutAuthorInput>; + connect?: Enumerable<PostWhereUniqueInput>; + }; + + export type IntFieldUpdateOperationsInput = { + set?: number; + increment?: number; + decrement?: number; + multiply?: number; + divide?: number; + }; + + export type StringFieldUpdateOperationsInput = { + set?: string; + }; + + export type NullableStringFieldUpdateOperationsInput = { + set?: string | null; + }; + + export type PostUpdateManyWithoutAuthorNestedInput = { + create?: XOR<Enumerable<PostCreateWithoutAuthorInput>, Enumerable<PostUncheckedCreateWithoutAuthorInput>>; + connectOrCreate?: Enumerable<PostCreateOrConnectWithoutAuthorInput>; + upsert?: Enumerable<PostUpsertWithWhereUniqueWithoutAuthorInput>; + set?: Enumerable<PostWhereUniqueInput>; + disconnect?: Enumerable<PostWhereUniqueInput>; + delete?: Enumerable<PostWhereUniqueInput>; + connect?: Enumerable<PostWhereUniqueInput>; + update?: Enumerable<PostUpdateWithWhereUniqueWithoutAuthorInput>; + updateMany?: Enumerable<PostUpdateManyWithWhereWithoutAuthorInput>; + deleteMany?: Enumerable<PostScalarWhereInput>; + }; + + export type PostUncheckedUpdateManyWithoutAuthorNestedInput = { + create?: XOR<Enumerable<PostCreateWithoutAuthorInput>, Enumerable<PostUncheckedCreateWithoutAuthorInput>>; + connectOrCreate?: Enumerable<PostCreateOrConnectWithoutAuthorInput>; + upsert?: Enumerable<PostUpsertWithWhereUniqueWithoutAuthorInput>; + set?: Enumerable<PostWhereUniqueInput>; + disconnect?: Enumerable<PostWhereUniqueInput>; + delete?: Enumerable<PostWhereUniqueInput>; + connect?: Enumerable<PostWhereUniqueInput>; + update?: Enumerable<PostUpdateWithWhereUniqueWithoutAuthorInput>; + updateMany?: Enumerable<PostUpdateManyWithWhereWithoutAuthorInput>; + deleteMany?: Enumerable<PostScalarWhereInput>; + }; + + export type UserCreateNestedOneWithoutPostsInput = { + create?: XOR<UserCreateWithoutPostsInput, UserUncheckedCreateWithoutPostsInput>; + connectOrCreate?: UserCreateOrConnectWithoutPostsInput; + connect?: UserWhereUniqueInput; + }; + + export type BoolFieldUpdateOperationsInput = { + set?: boolean; + }; + + export type UserUpdateOneRequiredWithoutPostsNestedInput = { + create?: XOR<UserCreateWithoutPostsInput, UserUncheckedCreateWithoutPostsInput>; + connectOrCreate?: UserCreateOrConnectWithoutPostsInput; + upsert?: UserUpsertWithoutPostsInput; + connect?: UserWhereUniqueInput; + update?: XOR<UserUpdateWithoutPostsInput, UserUncheckedUpdateWithoutPostsInput>; + }; + + export type NestedIntFilter = { + equals?: number; + in?: Enumerable<number> | number; + notIn?: Enumerable<number> | number; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedIntFilter | number; + }; + + export type NestedStringFilter = { + equals?: string; + in?: Enumerable<string> | string; + notIn?: Enumerable<string> | string; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringFilter | string; + }; + + export type NestedStringNullableFilter = { + equals?: string | null; + in?: Enumerable<string> | string | null; + notIn?: Enumerable<string> | string | null; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringNullableFilter | string | null; + }; + + export type NestedIntWithAggregatesFilter = { + equals?: number; + in?: Enumerable<number> | number; + notIn?: Enumerable<number> | number; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedIntWithAggregatesFilter | number; + _count?: NestedIntFilter; + _avg?: NestedFloatFilter; + _sum?: NestedIntFilter; + _min?: NestedIntFilter; + _max?: NestedIntFilter; + }; + + export type NestedFloatFilter = { + equals?: number; + in?: Enumerable<number> | number; + notIn?: Enumerable<number> | number; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedFloatFilter | number; + }; + + export type NestedStringWithAggregatesFilter = { + equals?: string; + in?: Enumerable<string> | string; + notIn?: Enumerable<string> | string; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringWithAggregatesFilter | string; + _count?: NestedIntFilter; + _min?: NestedStringFilter; + _max?: NestedStringFilter; + }; + + export type NestedStringNullableWithAggregatesFilter = { + equals?: string | null; + in?: Enumerable<string> | string | null; + notIn?: Enumerable<string> | string | null; + lt?: string; + lte?: string; + gt?: string; + gte?: string; + contains?: string; + startsWith?: string; + endsWith?: string; + not?: NestedStringNullableWithAggregatesFilter | string | null; + _count?: NestedIntNullableFilter; + _min?: NestedStringNullableFilter; + _max?: NestedStringNullableFilter; + }; + + export type NestedIntNullableFilter = { + equals?: number | null; + in?: Enumerable<number> | number | null; + notIn?: Enumerable<number> | number | null; + lt?: number; + lte?: number; + gt?: number; + gte?: number; + not?: NestedIntNullableFilter | number | null; + }; + + export type NestedBoolFilter = { + equals?: boolean; + not?: NestedBoolFilter | boolean; + }; + + export type NestedBoolWithAggregatesFilter = { + equals?: boolean; + not?: NestedBoolWithAggregatesFilter | boolean; + _count?: NestedIntFilter; + _min?: NestedBoolFilter; + _max?: NestedBoolFilter; + }; + + export type PostCreateWithoutAuthorInput = { + testId: number; + title: string; + content?: string | null; + published?: boolean; + }; + + export type PostUncheckedCreateWithoutAuthorInput = { + id?: number; + testId: number; + title: string; + content?: string | null; + published?: boolean; + }; + + export type PostCreateOrConnectWithoutAuthorInput = { + where: PostWhereUniqueInput; + create: XOR<PostCreateWithoutAuthorInput, PostUncheckedCreateWithoutAuthorInput>; + }; + + export type PostUpsertWithWhereUniqueWithoutAuthorInput = { + where: PostWhereUniqueInput; + update: XOR<PostUpdateWithoutAuthorInput, PostUncheckedUpdateWithoutAuthorInput>; + create: XOR<PostCreateWithoutAuthorInput, PostUncheckedCreateWithoutAuthorInput>; + }; + + export type PostUpdateWithWhereUniqueWithoutAuthorInput = { + where: PostWhereUniqueInput; + data: XOR<PostUpdateWithoutAuthorInput, PostUncheckedUpdateWithoutAuthorInput>; + }; + + export type PostUpdateManyWithWhereWithoutAuthorInput = { + where: PostScalarWhereInput; + data: XOR<PostUpdateManyMutationInput, PostUncheckedUpdateManyWithoutPostsInput>; + }; + + export type PostScalarWhereInput = { + AND?: Enumerable<PostScalarWhereInput>; + OR?: Enumerable<PostScalarWhereInput>; + NOT?: Enumerable<PostScalarWhereInput>; + id?: IntFilter | number; + testId?: IntFilter | number; + title?: StringFilter | string; + content?: StringNullableFilter | string | null; + published?: BoolFilter | boolean; + authorId?: IntFilter | number; + }; + + export type UserCreateWithoutPostsInput = { + testId: number; + email: string; + name?: string | null; + }; + + export type UserUncheckedCreateWithoutPostsInput = { + id?: number; + testId: number; + email: string; + name?: string | null; + }; + + export type UserCreateOrConnectWithoutPostsInput = { + where: UserWhereUniqueInput; + create: XOR<UserCreateWithoutPostsInput, UserUncheckedCreateWithoutPostsInput>; + }; + + export type UserUpsertWithoutPostsInput = { + update: XOR<UserUpdateWithoutPostsInput, UserUncheckedUpdateWithoutPostsInput>; + create: XOR<UserCreateWithoutPostsInput, UserUncheckedCreateWithoutPostsInput>; + }; + + export type UserUpdateWithoutPostsInput = { + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + }; + + export type UserUncheckedUpdateWithoutPostsInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + email?: StringFieldUpdateOperationsInput | string; + name?: NullableStringFieldUpdateOperationsInput | string | null; + }; + + export type PostUpdateWithoutAuthorInput = { + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + }; + + export type PostUncheckedUpdateWithoutAuthorInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + }; + + export type PostUncheckedUpdateManyWithoutPostsInput = { + id?: IntFieldUpdateOperationsInput | number; + testId?: IntFieldUpdateOperationsInput | number; + title?: StringFieldUpdateOperationsInput | string; + content?: NullableStringFieldUpdateOperationsInput | string | null; + published?: BoolFieldUpdateOperationsInput | boolean; + }; + + /** + * Batch Payload for updateMany & deleteMany & createMany + */ + + export type BatchPayload = { + count: number; + }; + + /** + * DMMF + */ + export const dmmf: runtime.BaseDMMF; +} diff --git a/test/package.json b/test/package.json index 49ae422c3..7722e0888 100644 --- a/test/package.json +++ b/test/package.json @@ -19,7 +19,9 @@ "undici": "^5.20.0", "socket.io": "^4.6.1", "socket.io-client": "^4.6.1", - "supertest": "^6.1.6" + "supertest": "^6.1.6", + "@prisma/client": "4.15.0", + "prisma": "4.15.0" }, "private": true, "scripts": { |