@ra-libs/nestjs
  • Home
  • interceptors
    • PrismaRAInterceptor
  • Utils
    • getFilterValue
    • includeReferencesIDs
    • includeRelations
    • removeOutputRelations
    • transformFindAllOutputArraysToIds
    • transformInputsToPrisma
    • transformOutputArraysToIds
    • withFilterField
    • withQSeach
Powered by GitBook
On this page
  1. Utils

includeRelations

Include relations specific fields or all fields depending on the input.

Usage

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

@Injectable()
export class Service {

    private relations = ["client", "seller.firstName"]

    findAll(query: any) {
        query = includeRelations(query, this.relations)
        ...
    }
}

the includeRelations used above will return a JSON

{
    ...query,
    include: {
        "client": true,
        "seller.select.firstName": true
    }
}
PreviousincludeReferencesIDsNextremoveOutputRelations

Last updated 2 years ago