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

removeOutputRelations

Remove relations fields from prisma results.

Usage

import { removeOutputRelations } from '@ra-libs/nestjs'

@Injectable()
export class Service {

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

    return this.prisma.$transaction([
      this.prisma.document.findMany(query),
      this.prisma.document.count({ where: query.where || {} }),
    ]).then(data => {
      return removeOutputRelations(data, this.relations)
    })
}

the removeOutputRelations used above will remove the client and seller field from the final results.

PreviousincludeRelationsNexttransformFindAllOutputArraysToIds

Last updated 2 years ago