# transformOutputArraysToIds

Transform prisma outputs relations to an array of strings instead of array of objects.

## Usage

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

@Injectable()
export class Service {
    
    findOne(id: string): Promise<Seller> {
        return this.prisma.seller.findUnique({
            where: { id },
            include: includeReferencesIDs(["sales"])
        })
    }
}
```

this will return a JSON

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

Using the transformOutputArraysToIds method as follow

```typescript
import { includeReferencesIDs, transformOutputArraysToIds } from '@ra-libs/nestjs'

@Injectable()
export class Service {
    
    findOne(id: string): Promise<Seller> {
        return this.prisma.seller.findUnique({
            where: { id },
            include: includeReferencesIDs(["sales"])
        }).then(transformOutputArraysToIds)
    }
}
```

will return a JSON

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

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/transformoutputarraystoids.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.
