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

prisma-extension-pagination

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-extension-pagination - npm Package Compare versions

Comparing version 0.2.4 to 0.3.1

0

dist/cursor.d.ts

@@ -0,0 +0,0 @@ import { CursorPaginationMeta } from ".";

6

dist/extension.d.ts
import { Prisma } from "@prisma/client";
import { PageNumberPaginationOptions, PageNumberPaginationMeta, CursorPaginationOptions, CursorPaginationMeta } from "./types";
export declare function paginate<T, A>(this: T, args?: Prisma.Exact<A, Omit<Prisma.Args<T, "findMany">, "cursor" | "take" | "skip">>): {
withPages: (options: PageNumberPaginationOptions) => Promise<[Prisma.Result<T, A, "findMany">, PageNumberPaginationMeta]>;
withCursor: (options: CursorPaginationOptions<Prisma.Result<T, A, "findMany">[number], NonNullable<Prisma.Args<T, "findMany">["cursor"]>>) => Promise<[Prisma.Result<T, A, "findMany">, CursorPaginationMeta]>;
export declare function paginate<T, A, TResult extends Prisma.Result<T, A, "findMany">>(this: T, args?: Prisma.Exact<A, Omit<Prisma.Args<T, "findMany">, "cursor" | "take" | "skip">>): {
withPages: <TOptions extends PageNumberPaginationOptions>(options: TOptions) => Promise<[TResult, PageNumberPaginationMeta<TOptions["includePageCount"]>]>;
withCursor: (options: CursorPaginationOptions<TResult[number], NonNullable<Prisma.Args<T, "findMany">["cursor"]>>) => Promise<[TResult, CursorPaginationMeta]>;
};

@@ -7,0 +7,0 @@ export declare const extension: (client: any) => import(".prisma/client").PrismaClient<any, any, any, {

@@ -0,0 +0,0 @@ export declare const resetSelection: {

@@ -0,0 +0,0 @@ import { extension, paginate } from "./extension";

@@ -20,4 +20,4 @@ import { Prisma } from '@prisma/client';

let pageCount = null;
let totalCount = null;
if (includePageCount) {
let totalCount;
[results, totalCount] = await Promise.all([model.findMany({

@@ -50,8 +50,13 @@ ...query,

return [results, {
isFirstPage: previousPage === null,
isLastPage: nextPage === null,
currentPage: page,
previousPage,
nextPage,
pageCount
...{
isFirstPage: previousPage === null,
isLastPage: nextPage === null,
currentPage: page,
previousPage,
nextPage
},
...(includePageCount === true ? {
pageCount,
totalCount
} : {})
}];

@@ -58,0 +63,0 @@ };

import { PageNumberPaginationMeta, PageNumberPaginationOptions, PrismaModel, PrismaQuery } from "./types";
type PaginateWithPagesOptions = Required<PageNumberPaginationOptions>;
export declare const paginateWithPages: (model: PrismaModel, query: PrismaQuery, { page, limit, includePageCount }: PaginateWithPagesOptions) => Promise<[unknown, PageNumberPaginationMeta]>;
export declare const paginateWithPages: (model: PrismaModel, query: PrismaQuery, { page, limit, includePageCount }: PaginateWithPagesOptions) => Promise<[unknown, PageNumberPaginationMeta<boolean>]>;
export {};

@@ -12,3 +12,3 @@ export type PrismaModel = {

};
export type PageNumberPaginationMeta = {
export type PageNumberPagination = {
isFirstPage: boolean;

@@ -19,4 +19,8 @@ isLastPage: boolean;

nextPage: number | null;
pageCount: number | null;
};
export type PageNumberCounters = {
pageCount: number;
totalCount: number;
};
export type PageNumberPaginationMeta<TWithCounters extends boolean | undefined = false> = TWithCounters extends true ? PageNumberPagination & PageNumberCounters : PageNumberPagination;
export type CursorPaginationOptions<Result, Condition> = {

@@ -23,0 +27,0 @@ limit: number;

{
"name": "prisma-extension-pagination",
"version": "0.2.4",
"version": "0.3.1",
"description": "Prisma Client extension for pagination",

@@ -46,15 +46,15 @@ "type": "module",

"devDependencies": {
"@types/jest": "^29.4.0",
"@types/node": "^18.14.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.4.3",
"jest": "^29.5.0",
"microbundle": "^0.15.1",
"prisma": "^4.9.0",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
"prisma": "^4.12.0",
"ts-jest": "^29.1.0",
"typescript": "^5.0.3"
}
}

@@ -69,3 +69,2 @@ # Prisma Pagination Extension

nextPage: 2,
pageCount: null,
}

@@ -91,3 +90,2 @@ ```

nextPage: 3,
pageCount: null,
}

@@ -115,2 +113,3 @@ ```

pageCount: 10, // the number of pages is calculated
totalCount: 100, // the total number of results is calculated
}

@@ -117,0 +116,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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