Search code examples
jsonindexingsplitrestler

Restler-3: index()-function


I'm playing around with Restler3 (really awesome!) and noticed a problem. So, the index() function should list all rows of a table, that's correct, right? I'm doing it that way: index() lists all rows of a table. But the client doesn't support to load an JSON object that's maybe about 50k rows big.

I think you can see the problem: I want to split that up in parts of maybe 50 rows. That would mean:

  1. Call index()
  2. Get number of queries to run (eg. 100rows would result in two queries)
  3. Call index(1) and save
  4. Call index(2) and save

My question is now: What's the best solution for that splitting? What do you think about my example? Can Restler already do such things?

Thank's for reading. Maybe you know something. Just answer…


Solution

  • This is a common problem faced by many API's see how twitter, Facebook and all are handling it

    Googling about API pagination will also help

    I suggest you add 2 optional parameters such as limit and offset and use them in your query

    On the api side you may specify limit = 50, and offset=0 and also set the minimum and maximum for limit using a comment such as {@min 10}{@max 100} then client wont be able to tax your server with big queries