# Prisma

You can use Transactional with Prisma client to run your queries in a transaction, this requires [interactive transactions](https://www.prisma.io/docs/concepts/components/prisma-client/transactions#interactive-transactions) to be supported by the client.

## Install

```bash
npm install @transactional/core @transactional/prisma
```

## Usage

```typescript
import { prismaTransactional } from "@transactional/prisma";

const prisma = new PrismaClient().$extends(prismaTransactional);
```

{% hint style="info" %}
Prisma transactional extensions run queries using the unextended client, so make sure to use the transactional extension after other extensions, like logging extensions or extensions that add methods to the client.
{% endhint %}

### Using `@Transactional` Decorator

```typescript
import { Transactional } from "@transactional/core"

class Service {
    
    @Transactional()
    findCats() {
        // now all your prisma queries are run inside the same transaction.
        await prisma.cat.findMany({});
        await prisma.cat.findFirst({});
        ...
    }
}
```

### Using `transactional` Method

```typescript
import { transactional } from "@transactional/core"

const findCats = transactional(() => {
    // now all your prisma queries are run inside the same transaction.
    return prisma.cat.findMany({});
})

await findCats();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://transactional.gitbook.io/documentation/clients/prisma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
