Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hiramhuang/779ec74a7548c4d5cfc127e5606e0ca4 to your computer and use it in GitHub Desktop.
Save hiramhuang/779ec74a7548c4d5cfc127e5606e0ca4 to your computer and use it in GitHub Desktop.

Revisions

  1. @aniravi24 aniravi24 revised this gist Mar 6, 2025. 1 changed file with 74 additions and 31 deletions.
    105 changes: 74 additions & 31 deletions prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -1,59 +1,54 @@
    import { Prisma } from "@prisma/client";
    import type { Replace } from "type-fest";
    import { Effect } from "effect";
    import type { Replace, UnionToTuple } from "type-fest";
    import { Effect, Option } from "effect";
    import { UnknownException } from "effect/Cause";

    type PrismaModelOp =
    | "aggregate"
    | "count"
    | "create"
    | "createMany"
    | "delete"
    | "deleteMany"
    type PrismaModelOp = Exclude<
    // You can import operation types from the generated Prisma client
    Operation,
    | "$executeRaw"
    | "$executeRawUnsafe"
    | "$queryRaw"
    | "$queryRawUnsafe"
    | "$runCommandRaw"
    | "aggregateRaw"
    | "findFirst"
    | "findFirstOrThrow"
    | "findMany"
    | "findRaw"
    | "findUnique"
    | "findUniqueOrThrow"
    | "groupBy"
    | "update"
    | "updateMany"
    | "upsert";
    >;

    const PrismaModelOps = [
    "aggregate",
    "count",
    const PrismaModelOps: UnionToTuple<PrismaModelOp> = [
    "findMany",
    "create",
    "createMany",
    "delete",
    "deleteMany",
    "findFirst",
    "findFirstOrThrow",
    "findMany",
    "findUnique",
    "findUniqueOrThrow",
    "groupBy",
    "createManyAndReturn",
    "update",
    "updateMany",
    "updateManyAndReturn",
    "upsert",
    ] as const satisfies readonly PrismaModelOp[];
    "delete",
    "deleteMany",
    "aggregate",
    "count",
    "groupBy",
    ] as const;

    export const prismaEffectExtension = {
    client: {
    // $executeRaw: (query: TemplateStringsArray | Sql, ...values: any[]) => PrismaPromise<number>
    $executeRawEffect: function <T>(
    this: T,
    // This type will work after generating the Prisma client
    query: Prisma.Sql | TemplateStringsArray,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ...values: any[]
    ): Effect.Effect<number, UnknownException, never> {
    return Effect.tryPromise<number>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$executeRaw"](
    query,
    ...values
    );
    return prismaExtensionContextClient["$executeRaw"](query, ...values);
    });
    },

    @@ -162,6 +157,54 @@ export const prismaEffectExtension = {
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never>;
    }),
    findFirstEffect<T, A, O extends "findFirstOrThrow">(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient.findFirstOrThrow(x);
    });
    },
    findFirstOption<T, A, O extends "findFirst">(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<
    Option.Option<NonNullable<Prisma.Result<T, A, O>>>,
    UnknownException,
    never
    > {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient.findFirst(x);
    }).pipe(Effect.map((result) => Option.fromNullable(result)));
    },
    findUniqueEffect<T, A, O extends "findUniqueOrThrow">(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient.findUniqueOrThrow(x);
    });
    },
    findUniqueOption<T, A, O extends "findUnique">(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<
    Option.Option<NonNullable<Prisma.Result<T, A, O>>>,
    UnknownException,
    never
    > {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient.findUnique(x);
    }).pipe(Effect.map((result) => Option.fromNullable(result)));
    },
    },
    },
    };
    };
  2. @aniravi24 aniravi24 revised this gist Mar 6, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ export const prismaEffectExtension = {
    return prismaExtensionContextClient["$executeRaw"](
    query,
    ...values
    ) as any;
    );
    });
    },

    @@ -164,4 +164,4 @@ export const prismaEffectExtension = {
    }),
    },
    },
    };
    };
  3. @aniravi24 aniravi24 revised this gist Mar 6, 2025. 1 changed file with 123 additions and 72 deletions.
    195 changes: 123 additions & 72 deletions prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -1,78 +1,124 @@
    import { Prisma } from '@prisma/client';
    import type { Replace } from 'type-fest';
    import { Effect } from 'effect';
    import { UnknownException } from 'effect/Cause';

    type PrismaClientOp = '$executeRaw' | '$executeRawUnsafe' | '$queryRaw' | '$queryRawUnsafe' | '$runCommandRaw';
    import { Prisma } from "@prisma/client";
    import type { Replace } from "type-fest";
    import { Effect } from "effect";
    import { UnknownException } from "effect/Cause";

    type PrismaModelOp =
    | 'aggregate'
    | 'count'
    | 'create'
    | 'createMany'
    | 'delete'
    | 'deleteMany'
    | 'findFirst'
    | 'findFirstOrThrow'
    | 'findMany'
    | 'findUnique'
    | 'findUniqueOrThrow'
    | 'groupBy'
    | 'update'
    | 'updateMany'
    | 'upsert';

    const PrismaClientOps = [
    '$executeRaw',
    '$executeRawUnsafe',
    '$queryRaw',
    '$queryRawUnsafe',
    '$runCommandRaw',
    ] as const satisfies readonly PrismaClientOp[];
    | "aggregate"
    | "count"
    | "create"
    | "createMany"
    | "delete"
    | "deleteMany"
    | "findFirst"
    | "findFirstOrThrow"
    | "findMany"
    | "findUnique"
    | "findUniqueOrThrow"
    | "groupBy"
    | "update"
    | "updateMany"
    | "upsert";

    const PrismaModelOps = [
    'aggregate',
    'count',
    'create',
    'createMany',
    'delete',
    'deleteMany',
    'findFirst',
    'findFirstOrThrow',
    'findMany',
    'findUnique',
    'findUniqueOrThrow',
    'groupBy',
    'update',
    'updateMany',
    'upsert',
    "aggregate",
    "count",
    "create",
    "createMany",
    "delete",
    "deleteMany",
    "findFirst",
    "findFirstOrThrow",
    "findMany",
    "findUnique",
    "findUniqueOrThrow",
    "groupBy",
    "update",
    "updateMany",
    "upsert",
    ] as const satisfies readonly PrismaModelOp[];


    export const prismaEffectExtension = {
    client: {
    ...(Object.fromEntries(
    PrismaClientOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    // eslint-disable-next-line no-invalid-this
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return prismaExtensionContextClient[method](x) as any;
    });
    },
    ]),
    ) as {
    [K in `${(typeof PrismaClientOps)[number]}Effect`]: <T, A, O extends Replace<K, 'Effect', ''>>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    ) => Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never>;
    }),
    // $executeRaw: (query: TemplateStringsArray | Sql, ...values: any[]) => PrismaPromise<number>
    $executeRawEffect: function <T>(
    this: T,
    query: Prisma.Sql | TemplateStringsArray,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ...values: any[]
    ): Effect.Effect<number, UnknownException, never> {
    return Effect.tryPromise<number>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$executeRaw"](
    query,
    ...values
    ) as any;
    });
    },

    // $executeRawUnsafe: (query: string, ...values: any[]) => PrismaPromise<number>
    $executeRawUnsafeEffect: function <T>(
    this: T,
    query: string,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ...values: any[]
    ): Effect.Effect<number, UnknownException, never> {
    return Effect.tryPromise<number>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$executeRawUnsafe"](
    query,
    ...values
    );
    });
    },

    // $queryRaw: <T = unknown>(query: TemplateStringsArray | Sql, ...values: any[]) => PrismaPromise<T>
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    $queryRawEffect: function <A = unknown, T = any>(
    this: T,
    query: Prisma.Sql | TemplateStringsArray,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ...values: any[]
    ): Effect.Effect<A, UnknownException, never> {
    return Effect.tryPromise<A>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$queryRaw"](query, ...values);
    });
    },

    // $queryRawTyped: <T>(query: TypedSql<unknown[], T>) => PrismaPromise<T[]>
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    $queryRawTypedEffect: function <A = unknown, T = any>(
    this: T,
    query: TypedSql<unknown[], T>
    ): Effect.Effect<A, UnknownException, never> {
    return Effect.tryPromise<A>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$queryRawTyped"](query);
    });
    },

    // $queryRawUnsafe: <T = unknown>(query: string, ...values: any[]) => PrismaPromise<T>
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    $queryRawUnsafeEffect: function <A = unknown, T = any>(
    this: T,
    query: string,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ...values: any[]
    ): Effect.Effect<A, UnknownException, never> {
    return Effect.tryPromise<A>(() => {
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    return prismaExtensionContextClient["$queryRawUnsafe"](
    query,
    ...values
    );
    });
    },
    },
    model: {
    $allModels: {
    @@ -88,7 +134,7 @@ export const prismaEffectExtension = {
    // For `customCall`, use the arguments from model `T` and the
    // operation `findFirst`. Add `customProperty` to the operation.
    Prisma.Args<T, O>
    >,
    >

    // Get the correct result types for the model of type `T`,
    // and the arguments of type `A` for `findFirst`.
    @@ -98,17 +144,22 @@ export const prismaEffectExtension = {
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    // eslint-disable-next-line no-invalid-this
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    const prismaExtensionContextClient =
    Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return prismaExtensionContextClient[method](x) as any;
    });
    },
    ]),
    ])
    ) as {
    [K in `${(typeof PrismaModelOps)[number]}Effect`]: <T, A, O extends Replace<K, 'Effect', ''>>(
    [K in `${(typeof PrismaModelOps)[number]}Effect`]: <
    T,
    A,
    O extends Replace<K, "Effect", "">,
    >(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never>;
    }),
    },
  4. @aniravi24 aniravi24 revised this gist Jan 22, 2025. 1 changed file with 93 additions and 106 deletions.
    199 changes: 93 additions & 106 deletions prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -1,129 +1,116 @@
    type PrismaClientOp =
    | "$executeRaw"
    | "$executeRawUnsafe"
    | "$queryRaw"
    | "$queryRawUnsafe"
    | "$runCommandRaw";
    import { Prisma } from '@prisma/client';
    import type { Replace } from 'type-fest';
    import { Effect } from 'effect';
    import { UnknownException } from 'effect/Cause';

    type PrismaClientOp = '$executeRaw' | '$executeRawUnsafe' | '$queryRaw' | '$queryRawUnsafe' | '$runCommandRaw';

    type PrismaModelOp =
    | "aggregate"
    | "count"
    | "create"
    | "createMany"
    | "delete"
    | "deleteMany"
    | "findFirst"
    | "findFirstOrThrow"
    | "findMany"
    | "findUnique"
    | "findUniqueOrThrow"
    | "groupBy"
    | "update"
    | "updateMany"
    | "upsert";
    | 'aggregate'
    | 'count'
    | 'create'
    | 'createMany'
    | 'delete'
    | 'deleteMany'
    | 'findFirst'
    | 'findFirstOrThrow'
    | 'findMany'
    | 'findUnique'
    | 'findUniqueOrThrow'
    | 'groupBy'
    | 'update'
    | 'updateMany'
    | 'upsert';

    const PrismaClientOps = [
    "$executeRaw",
    "$executeRawUnsafe",
    "$queryRaw",
    "$queryRawUnsafe",
    "$runCommandRaw",
    '$executeRaw',
    '$executeRawUnsafe',
    '$queryRaw',
    '$queryRawUnsafe',
    '$runCommandRaw',
    ] as const satisfies readonly PrismaClientOp[];

    const PrismaModelOps = [
    // TODO These need to be implemented at the client level, not at the model level
    // "$executeRaw",
    // "$executeRawUnsafe",
    // "$queryRaw",
    // "$queryRawUnsafe",
    // "$runCommandRaw",
    "aggregate",
    "count",
    "create",
    "createMany",
    "delete",
    "deleteMany",
    "findFirst",
    "findFirstOrThrow",
    "findMany",
    "findUnique",
    "findUniqueOrThrow",
    "groupBy",
    "update",
    "updateMany",
    "upsert",
    'aggregate',
    'count',
    'create',
    'createMany',
    'delete',
    'deleteMany',
    'findFirst',
    'findFirstOrThrow',
    'findMany',
    'findUnique',
    'findUniqueOrThrow',
    'groupBy',
    'update',
    'updateMany',
    'upsert',
    ] as const satisfies readonly PrismaModelOp[];

    export const prisma = new PrismaClient().$extends({

    export const prismaEffectExtension = {
    client: {
    $allModels: Object.fromEntries(
    ...(Object.fromEntries(
    PrismaClientOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<never, never, Prisma.Result<T, A, O>> {
    // @ts-expect-error Can't predict these in advance
    return Effect.tryCatchPromise(
    // @ts-expect-error Can't predict these in advance
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    // eslint-disable-next-line no-invalid-this
    () => this[method](x) as any,
    // handle error case however you want
    );
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return prismaExtensionContextClient[method](x) as any;
    });
    },
    ])
    ]),
    ) as {
    [K in `${typeof PrismaClientOps[number]}Effect`]: <
    T,
    A,
    O extends Replace<K, "Effect", "">
    >(
    [K in `${(typeof PrismaClientOps)[number]}Effect`]: <T, A, O extends Replace<K, 'Effect', ''>>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<never, never, Prisma.Result<T, A, O>>;
    },
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    ) => Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never>;
    }),
    },
    model: {
    $allModels: Object.fromEntries(
    PrismaModelOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    // `this` is the current type (for example
    // it might be `prisma.user` at runtime).
    this: T,
    x?: Prisma.Exact<
    A,
    // For `customCall`, use the arguments from model `T` and the
    // operation `findFirst`. Add `customProperty` to the operation.
    Prisma.Args<T, O>
    >
    $allModels: {
    ...(Object.fromEntries(
    PrismaModelOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    // `this` is the current type (for example
    // it might be `prisma.user` at runtime).
    this: T,
    x?: Prisma.Exact<
    A,
    // For `customCall`, use the arguments from model `T` and the
    // operation `findFirst`. Add `customProperty` to the operation.
    Prisma.Args<T, O>
    >,

    // Get the correct result types for the model of type `T`,
    // and the arguments of type `A` for `findFirst`.
    // `Prisma.Result` computes the result for a given operation
    // such as `select {id: true}` in function `main` below.
    //
    ): Effect.Effect<never, never, Prisma.Result<T, A, O>> {
    // Override type safety here, because we cannot
    // predict the result types in advance.
    // @ts-expect-error Can't predict these in advance
    return Effect.tryCatchPromise(
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line no-invalid-this
    () => this[method](x) as any,
    // handle error case however you want
    );
    },
    ])
    ) as {
    [K in `${typeof PrismaModelOps[number]}Effect`]: <
    T,
    A,
    O extends Replace<K, "Effect", "">
    >(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<never, never, Prisma.Result<T, A, O>>;
    // Get the correct result types for the model of type `T`,
    // and the arguments of type `A` for `findFirst`.
    // `Prisma.Result` computes the result for a given operation
    // such as `select {id: true}` in function `main` below.
    //,
    ): Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never> {
    return Effect.tryPromise<Prisma.Result<T, A, O>>(() => {
    // eslint-disable-next-line no-invalid-this
    const prismaExtensionContextClient = Prisma.getExtensionContext(this);
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return prismaExtensionContextClient[method](x) as any;
    });
    },
    ]),
    ) as {
    [K in `${(typeof PrismaModelOps)[number]}Effect`]: <T, A, O extends Replace<K, 'Effect', ''>>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>,
    ) => Effect.Effect<Prisma.Result<T, A, O>, UnknownException, never>;
    }),
    },
    },
    });
    };
  5. @aniravi24 aniravi24 revised this gist Jun 6, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ const PrismaModelOps = [
    "upsert",
    ] as const satisfies readonly PrismaModelOp[];

    export const rawPrismaClient = new PrismaClient().$extends({
    export const prisma = new PrismaClient().$extends({
    client: {
    $allModels: Object.fromEntries(
    PrismaClientOps.map((method) => [
  6. @aniravi24 aniravi24 created this gist Jun 6, 2024.
    129 changes: 129 additions & 0 deletions prisma-effect-extension.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,129 @@
    type PrismaClientOp =
    | "$executeRaw"
    | "$executeRawUnsafe"
    | "$queryRaw"
    | "$queryRawUnsafe"
    | "$runCommandRaw";

    type PrismaModelOp =
    | "aggregate"
    | "count"
    | "create"
    | "createMany"
    | "delete"
    | "deleteMany"
    | "findFirst"
    | "findFirstOrThrow"
    | "findMany"
    | "findUnique"
    | "findUniqueOrThrow"
    | "groupBy"
    | "update"
    | "updateMany"
    | "upsert";

    const PrismaClientOps = [
    "$executeRaw",
    "$executeRawUnsafe",
    "$queryRaw",
    "$queryRawUnsafe",
    "$runCommandRaw",
    ] as const satisfies readonly PrismaClientOp[];

    const PrismaModelOps = [
    // TODO These need to be implemented at the client level, not at the model level
    // "$executeRaw",
    // "$executeRawUnsafe",
    // "$queryRaw",
    // "$queryRawUnsafe",
    // "$runCommandRaw",
    "aggregate",
    "count",
    "create",
    "createMany",
    "delete",
    "deleteMany",
    "findFirst",
    "findFirstOrThrow",
    "findMany",
    "findUnique",
    "findUniqueOrThrow",
    "groupBy",
    "update",
    "updateMany",
    "upsert",
    ] as const satisfies readonly PrismaModelOp[];

    export const rawPrismaClient = new PrismaClient().$extends({
    client: {
    $allModels: Object.fromEntries(
    PrismaClientOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ): Effect.Effect<never, never, Prisma.Result<T, A, O>> {
    // @ts-expect-error Can't predict these in advance
    return Effect.tryCatchPromise(
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line no-invalid-this
    () => this[method](x) as any,
    // handle error case however you want
    );
    },
    ])
    ) as {
    [K in `${typeof PrismaClientOps[number]}Effect`]: <
    T,
    A,
    O extends Replace<K, "Effect", "">
    >(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<never, never, Prisma.Result<T, A, O>>;
    },
    },
    model: {
    $allModels: Object.fromEntries(
    PrismaModelOps.map((method) => [
    `${method}Effect`,
    function <T, A, O extends typeof method>(
    // `this` is the current type (for example
    // it might be `prisma.user` at runtime).
    this: T,
    x?: Prisma.Exact<
    A,
    // For `customCall`, use the arguments from model `T` and the
    // operation `findFirst`. Add `customProperty` to the operation.
    Prisma.Args<T, O>
    >

    // Get the correct result types for the model of type `T`,
    // and the arguments of type `A` for `findFirst`.
    // `Prisma.Result` computes the result for a given operation
    // such as `select {id: true}` in function `main` below.
    //
    ): Effect.Effect<never, never, Prisma.Result<T, A, O>> {
    // Override type safety here, because we cannot
    // predict the result types in advance.
    // @ts-expect-error Can't predict these in advance
    return Effect.tryCatchPromise(
    // @ts-expect-error Can't predict these in advance
    // eslint-disable-next-line no-invalid-this
    () => this[method](x) as any,
    // handle error case however you want
    );
    },
    ])
    ) as {
    [K in `${typeof PrismaModelOps[number]}Effect`]: <
    T,
    A,
    O extends Replace<K, "Effect", "">
    >(
    this: T,
    x?: Prisma.Exact<A, Prisma.Args<T, O>>
    ) => Effect.Effect<never, never, Prisma.Result<T, A, O>>;
    },
    },
    });