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

prisma-pagination

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-pagination - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

dist/index.js

@@ -1,2 +0,2 @@

function e(){return e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},e.apply(this,arguments)}exports.createPaginator=function(r){var t=Number(r.page)||1,n=Number(r.perPage)||10;return function(r,a,o){void 0===a&&(a={where:void 0});try{t=Number(null==o?void 0:o.page)||t,n=Number(null==o?void 0:o.perPage)||n;var u=t>0?n*(t-1):0;return Promise.resolve(Promise.all([r.count({where:a.where}),r.findMany(e({},a,{take:n,skip:u}))])).then(function(e){var r=e[0],a=e[1],o=Math.ceil(r/n);return{data:a,meta:{total:r,lastPage:o,currentPage:t,perPage:n,prev:t>1?t-1:null,next:t<o?t+1:null}}})}catch(e){return Promise.reject(e)}}};
function e(){return e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},e.apply(this,arguments)}exports.createPaginator=function(r){return function(t,n,a){void 0===n&&(n={where:void 0});try{var o=Number((null==a?void 0:a.page)||(null==r?void 0:r.page))||1,l=Number((null==a?void 0:a.perPage)||(null==r?void 0:r.perPage))||10,i=o>0?l*(o-1):0;return Promise.resolve(Promise.all([t.count({where:n.where}),t.findMany(e({},n,{take:l,skip:i}))])).then(function(e){var r=e[0],t=e[1],n=Math.ceil(r/l);return{data:t,meta:{total:r,lastPage:n,currentPage:o,perPage:l,prev:o>1?o-1:null,next:o<n?o+1:null}}})}catch(e){return Promise.reject(e)}}};
//# sourceMappingURL=index.js.map
{
"name": "prisma-pagination",
"version": "0.2.1",
"version": "0.2.2",
"description": "",

@@ -32,2 +32,2 @@ "source": "src/index.ts",

}
}
}

@@ -16,9 +16,6 @@ export interface PaginatedResult<T> {

export const createPaginator = (options: PaginateOptions): PaginateFunction => {
let page: number = Number(options.page) || 1
let perPage: number = Number(options.perPage) || 10
export const createPaginator = (defaultOptions: PaginateOptions): PaginateFunction => {
return async (model, args: any = { where: undefined }, options) => {
page = Number(options?.page) || page
perPage = Number(options?.perPage) || perPage
const page = Number(options?.page || defaultOptions?.page) || 1
const perPage = Number(options?.perPage || defaultOptions?.perPage) || 10

@@ -25,0 +22,0 @@ const skip = page > 0 ? perPage * (page - 1) : 0

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