About | Technologies | Requirements | Getting started | License | Author
Pagination based on the indexeddb module idbx.
The following tools were used in this project:
- idbx - an indexedDB wrapper
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";
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);
- Proper documentation
This project is under license from MIT. For more details, see the LICENSE file.
Made by Mario Stöcklein