Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to handle query cursor? #15

Open
xnopasaranx opened this issue Jan 24, 2018 · 1 comment
Open

how to handle query cursor? #15

xnopasaranx opened this issue Jan 24, 2018 · 1 comment
Labels

Comments

@xnopasaranx
Copy link

Hello there! We are trying to implement kingTable into our software.
However I cannot get it working as expected. I am trying to request data from the server and prepare this as JSON for kingtable to read. I have to limit my query to 99 objects and therefore need to pass a cursor to continue, and I can provide the total number of expected entries.

Is there any possibility to pass on a query cursor to kingTable?

@RobertoPrevato
Copy link
Owner

Hello!
The library creates pagination automatically and sends GET requests with the following key-values inside the query string (example):

  "page": 1,
  "size": 30,
  "sortBy": "name asc, color desc, red asc",
  "search": null,
  "timestamp": "2017-04-29T19:08:36.800Z"

It expects a response object with the following information:

{
  items: [array], // array of items that respect the given filters (set of paginated results)
  total: [number] // the total count of items inside the collection (for example, the result of SQL Count(*))
}

Unfortunately it doesn't support, yet, scenarios in which the total count of items cannot be determined on the server side (for example, when using Azure Storage Table Service with continuation tokens). But I understand it's not this case, since you wrote that you can provide the total number of expected entries.

If you desire to add extra parameters to the query string or POST request body, you can use the option fetchData:

var table = new KingTable({
    fetchData: function () {
       // function called in the table context
       return {
          extraParam: 2
       };
    }
})

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants