Wondering what’s next for npm?Check out our public roadmap! »

This package has been deprecated

Author message:

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

relay-sequelize-pagination

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
        }
    );
}

Install

npm i relay-sequelize-pagination

DownloadsWeekly Downloads

4

Version

0.0.2

License

MIT

Last publish

Collaborators

  • avatar