relay-sequelize-pagination

Relay Cursor-Based Pagination Support for Sequelize

WARNING: This project has been renamed to relay-cursor-paging.
Last updated 5 years ago by darthtrevino .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install relay-sequelize-pagination 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.2                                ...           latest (5 years ago)

2 Versions

  • 0.0.2 [deprecated]           ...           5 years ago
  • 0.0.1 [deprecated]           ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |