# transformFindAllOutputArraysToIds

Transform prisma outputs relations to an array of strings instead of array of objects. this method uses the [transformOutputArraysToIds](/nestjs/utils/transformoutputarraystoids.md) method but it handles the $transaction response as it returns an array of data and the count field.

## Usage

```typescript

@Injectable()
export class Service {
    
  findAll(query: any): Promise<[Client[], number]> {
    const where = query.where || {};
    return this.prisma.$transaction([
      this.prisma.client.findMany(query),
      this.prisma.client.count({ where }),
    ]);
  }
}
```

this will return a JSON

```typescript
[
    [
        {
            "id": "<id>",
            ...
            "sales": [
                { "id": "<id_1>" },
                { "id": "<id_2>" }
            ]
        }
    ],
    1
]
```

Using the transformFindAllOutputArraysToIds method as follow

```typescript
import { transformFindAllOutputArraysToIds } from '@ra-libs/nestjs'

@Injectable()
export class Service {
    
  findAll(query: any): Promise<[Client[], number]> {
    const where = query.where || {};
    return this.prisma.$transaction([
      this.prisma.client.findMany(query),
      this.prisma.client.count({ where }),
    ]).then(transformFindAllOutputArraysToIds)
  }
}
```

will return a JSON

```typescript
[
    [
        {
            "id": "<id>",
            ...
            "sales": [
                "<id_1>",
                "<id_2>"
            ]
        }
    ],
    1
]
```

This is useful with react-admin as it expects an array of IDs instead of array of objects.


---

# 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://ra-libs.gitbook.io/nestjs/utils/transformfindalloutputarraystoids.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.
