Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sequelize-typescript-paginate

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sequelize-typescript-paginate

Sequelize Model with pagination for Sequelize-Typescript

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

sequelize-typescript-paginate

npm version Coverage Status

Sequelize Base Model with pagination for Sequelize-Typescript

Inspired on https://github.com/eclass/sequelize-paginate

Installation

npm i sequelize-typescript-paginate

Usege

import { PaginatedModel } from 'sequelize-typescript-pagination';
import { Sequelize, Column, DataType, ForeignKey, Table, HasMany } from 'sequelize-typescript';

@Table({ tableName: 'book' })
export class Book extends PaginatedModel {
  @Column({ type: DataType.STRING })
  name: string;
  @ForeignKey(() => Author)
  @Column({ type: DataType.INTEGER })
  authorId: string;
}

@Table({ tableName: 'author' })
export class Author extends PaginatedModel {
  @Column({ type: DataType.STRING })
  name: string;
  @HasMany(() => Book)
  books: Book[];
}

//...
//...
//...

// Default page = 1 and pageSize = 25
const { docs, pages, total } = await Author.paginate();
// Or with extra options
const options = {
  attributes: ['id', 'name'],
  page: 1, // Default 1
  pageSize: 25, // Default 25
  order: [['name', 'DESC']],
  where: { name: { [Op.like]: `%elliot%` } },
};
const { docs, pages, total } = await Author.paginate(options);

NOTE: If options includes limit or offset they will be ignored.

License

MIT

Keywords

FAQs

Package last updated on 31 Dec 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc