Rebasely Beta: data may be purged

examples/storefront Public

Page through the product list with a cursor #1

  1. Justin Torre opened this

    GET /products returned the first 100 active products and stopped there. The catalog page shows 24 at a time and the merchant is past 100, so this adds paging.

    What changes

    • GET /products takes ?limit= (1 to 100, default 24) and ?after=, and returns { products, next }. next is null on the last page.
    • The cursor is the (name, id) of the last product on the page, base64url encoded. The query continues with (name, id) > (?, ?) on the existing products_by_name index, so every page is one range scan and pages do not shift when a product is added or retired between requests.
    • A bad limit or a cursor that does not decode is a 400 (bad_limit, bad_cursor).
    • The catalog note in the knowledge base has a Paging section.

    Compatibility

    The response gains next. A client that ignores it now gets the first 24 products instead of up to 100, so the catalog page has to follow next to show more.

    Testing

    npm test covers three full pages, products sharing a name, a product added before the cursor, and bad parameters.

  2. Justin Torre merged commit 94db762 into main and deleted paginate-products

Merged

Merged into main

Justin Torre merged as 94db762 (create a merge commit).

Sign in to comment.