home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 782708938

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/782#issuecomment-782708938 https://api.github.com/repos/simonw/datasette/issues/782 782708938 MDEyOklzc3VlQ29tbWVudDc4MjcwODkzOA== 9599 2021-02-20T16:22:14Z 2021-02-20T16:22:14Z OWNER

I'm leaning back in the direction of a flat JSON array of objects as the default - this:

/fixtures/roadside_attractions.json

Would return:

json [ { "pk": 1, "name": "The Mystery Spot", "address": "465 Mystery Spot Road, Santa Cruz, CA 95065", "latitude": 37.0167, "longitude": -122.0024 }, { "pk": 2, "name": "Winchester Mystery House", "address": "525 South Winchester Boulevard, San Jose, CA 95128", "latitude": 37.3184, "longitude": -121.9511 }, { "pk": 3, "name": "Burlingame Museum of PEZ Memorabilia", "address": "214 California Drive, Burlingame, CA 94010", "latitude": 37.5793, "longitude": -122.3442 }, { "pk": 4, "name": "Bigfoot Discovery Museum", "address": "5497 Highway 9, Felton, CA 95018", "latitude": 37.0414, "longitude": -122.0725 } ] To get the version that includes pagination information you would use the ?_extra= parameter. For example:

/fixtures/roadside_attractions.json?_extra=total&_extra=next_url

json { "rows": [ { "pk": 1, "name": "The Mystery Spot", "address": "465 Mystery Spot Road, Santa Cruz, CA 95065", "latitude": 37.0167, "longitude": -122.0024 }, { "pk": 2, "name": "Winchester Mystery House", "address": "525 South Winchester Boulevard, San Jose, CA 95128", "latitude": 37.3184, "longitude": -121.9511 }, { "pk": 3, "name": "Burlingame Museum of PEZ Memorabilia", "address": "214 California Drive, Burlingame, CA 94010", "latitude": 37.5793, "longitude": -122.3442 }, { "pk": 4, "name": "Bigfoot Discovery Museum", "address": "5497 Highway 9, Felton, CA 95018", "latitude": 37.0414, "longitude": -122.0725 } ], "total": 4, "next_url": null } ANY usage of the ?_extra= parameter would turn the list into an object with a "rows" key.

Opting in to the total is nice because it's actually expensive to run a count, so only doing a count if the user requests it feels good.

But... having to add ?_extra=total&_extra=next_url for the common case of wanting both the total count and the URL to get the next page of results is a bit verbose. So maybe support aliases, like ?_extra=paginated which is a shortcut for ?_extra=total&_extra=next_url?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
627794879  
Powered by Datasette · Queries took 1.02ms · About: github-to-sqlite