nestjs-prisma-querybuilder-interface
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

Nestjs/prisma-querybuilder-interface

https://nestjs.com/img/logo_text.svg


Use case

this is a frontend interface to nestjs-prisma-querybuilder


What's new

  • Filter in Populate

    You can filter inside populate

  • Insensitive Case

    now in the filter you can search with insensitive case


Documentation

  • How to install it?

    npm

    npm install --save nestjs-prisma-querybuilder-interface

    yarn

    yarn add nestjs-prisma-querybuilder-interface
  • Properties

    • Usage

      Name Type exemple
      select string select: 'name email',
      page number page: 2,
      limit number limit: 20,
      sort SortFields sort: {field: string, criteria: 'asc'},
      populate Populate populate: [{path: 'car', select: 'model plate'}]
      filter Filter filter: [{name: 'jonas'}, {value: { gte: 4 }}]

  • Exported Interfaces

    import {
      Query,
      Populate,
      Filter
    } from 'nestjs-prisma-querybuilder-interface';
    • Query

      all types

    • Populate

    • Filter

    • Operators

      contains, endsWith, startsWith, equals, gt, gte, in, lt, lte ,not, notIn, hasEvery, hasSome, has, isEmpty;


  • Full usage exemple

    QueryString({
      select: 'firstName picture',
      populate: [
        {
          path: 'car',
          select: 'model plate',
          populate: [
            {
              path: 'brand',
              select: 'name'
            }
          ]
        }
      ],
      filter: [
        {
          path: 'plate',
          value: 'XFS1T67'
        }
      ]
    });
  • Populate

    const populate: Populate = [
      {
        path: 'car',
        select: 'model plate',
        filter: [{ path: 'name', value: 'ford', operator: 'contains' }],
        populate: [
          {
            path: 'brand',
            select: 'name'
          }
        ],
        primaryKey: 'yourTablePrimaryKey' // default 'id'
      }
    ];
  • Filter

    const filter: Filter = [
      {
        path: 'createdAt',
        value: new Date(),
        operator: 'lte'
      },
      {
        or: [
          {
            path: 'role',
            value: 'admin',
            operator: 'equals'
          },
          {
            path: 'role',
            value: 'system',
            operator: 'equals'
          }
        ]
      },
      {
        and: [
          {
            path: 'name',
            value: 'Ricky',
            operator: 'equals',
            insensitive: true
          },
          {
            path: 'lastName',
            value: 'Morty',
            operator: 'contains',
            insensitive: true
          }
        ]
      }
    ];

END

  • Nestjs/Prisma Querybuilder Interface is ISC licensed.

Hits

Package Sidebar

Install

npm i nestjs-prisma-querybuilder-interface

Weekly Downloads

12

Version

1.4.0

License

ISC

Unpacked Size

27.5 kB

Total Files

36

Last publish

Collaborators

  • willian-rodrigues