This package has been deprecated

Author message:

WARNING: This project has been renamed to relay-cursor-paging.

relay-sequelize-pagination
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Build Status

relay-sequelize-pagination

Relay Cursor-Based Pagination Support for Sequelize

This microlibrary exports a function that will mutate the limit and criteria fields of a Sequelize FindOptions object with values based on Relay's pagination fields (e.g. first, after, last, and before).

const {addCursorPagingCriteria} = require("relay-sequelize-pagination").default;
 
resolve: (root, args) => {
    const criteria = makeCriteriaForMyDomain(args); // An 'order' property should be added to the criteria here or in your repository.
    addCursorPagingCriteria(criteria, args);
                                   
    return connectionFromPromisedArraySlice(
        myRepository.findAll(criteria),
        args, 
        {
            sliceStart: criteria.offset, 
            arrayLength: Number.MAX_VALUE // or the result of a count query
        }
    );
}

Package Sidebar

Install

npm i relay-sequelize-pagination

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • darthtrevino