Socket
Book a DemoInstallSign in
Socket

nestjs-pagination-typeorm

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

nestjs-pagination-typeorm

Paginate and sort helpers for TypeORM and NestJS.

0.0.1
unpublished
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

nestjs-pagination-typeorm

Paginate and sort helpers for TypeORM and NestJS.

  • Filter operators (eq, like, ne, gt, gte, in, lt, lte, btw)
  • Sort by multiple columns
  • Paginate with cursor or offset
  • Order results by multiple columns
  • Extends typeorm added Unit of work pattern (transactional queries)

Documentation in progress

Installation

$ npm install --save nestjs-pagination-typeorm

Usage

Create Repository

import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { BaseRepository } from "nestjs-pagination-typeorm";

export class UserRepository extends BaseRepository<User> {
  public constructor(@InjectRepository(User) repository: Repository<User>) {
    super(User);
  }
}

Create Service

import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { UserRepository } from "./user.repository";

@Injectable()
export class UserService {
  public constructor(
    @InjectRepository(UserRepository)
    private readonly userRepository: UserRepository,
  ) {}

  public async findAll(filter: PaginationFilter<User>): Promise<PaginationResult<User>> {
    return this.userRepository.paginate(filter);
  }
}

Create Controller

import { Controller, Get, Query } from "@nestjs/common";
import { Paginate, PaginationDto } from "nestjs-pagination-typeorm";
import { UserService } from "./user.service";

@Controller("users")
export class UserController {
  public constructor(private readonly userService: UserService) {}

  @Get()
  public async findAll(@Paginate() filter: PaginationFilter<User>): Promise<PaginationDto<User>> {
    return this.userService.findAll(filter);
  }
}

Keywords

nestjs

FAQs

Package last updated on 01 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.