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

withQSeach

withQSearch adds the q filter to the query, it extracts it from the query and map it to the fields.

Usage

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


  findAll(query: any): Promise<[Client[], number]> {
    query = withQSearch(query, ["firstName", "lastName", "email", "document", "cellphone"])
    const where = query.where || {};
    return this.prisma.$transaction([
      this.prisma.client.findMany(query),
      this.prisma.client.count({ where }),
    ]);
  }

In the example shown above the withQSearch will extract the q field value and search in firstName, lastName, email, document, cellphone fields.

PreviouswithFilterField

Last updated 2 years ago