Skip to content

xpectme/idpaging

Repository files navigation

IDBPaging

 

IDBPaging

Github top language Github language count Repository size License


About   |   Technologies   |   Requirements   |   Getting started   |   License   |   Author


About

Pagination based on the indexeddb module idbx.

Technologies

The following tools were used in this project:

  • idbx - an indexedDB wrapper

Getting started

Deno:

import {IDBPaging} from "https://deno.land/x/idbpaging/mod.ts";

NodeJS/Deno (same thing):

import {IDBPaging} from "npm:idbpaging";

Browser:

import {IDBPaging} from "https://esm.sh/idbpaging";

Usage

Pages start by 1.

const pageSize = 10;
const paging = new IDBPaging(db, storeName, pageSize);

// get first page
var list = await paging.first();

// get last page
var list = await paging.last();

// get next page
var list = await paging.next();

// get previous page
var list = await paging.prev();

// get page by index
var list = await paging.go(1);

// count pages
var totalPages = await paging.count();

// list of items for the current page
var list = await paging.list;

// current page number
var pageNumber = await paging.pageNumber;

// items per page
var pageSize = await paging.pageSize;

// total number of pages
var totalPages = await paging.totalPages;

You can enable circular paging on-the-fly:

await paging.first();
// go to the last page by circular paging
await paging.prev(1, true);

await paging.first();
// you can even go further back or forth by circular paging
// If you have 10 pages, this will go to page 7
await paging.prev(3, true);

await paging.last();
// go to the first page by circular paging
await paging.next(1, true);

await paging.last();
// you can even go further back or forth by circular paging
// If you have 10 pages, this will go to page 3
await paging.next(3, true);

ToDo

  • Proper documentation

License

This project is under license from MIT. For more details, see the LICENSE file.

Made by Mario Stöcklein

 

Back to top