scraperwiki/dumptruck-web — pull request #6 by zarino (2013-10-29 22:55:45+00:00)
Title: Show _grids in meta endpoint

Having written `_grids` support into both the Table Xtract tool and the Spreadsheet Download tool, I figured it might be a good idea to support `_grids` at the SQL API level.

This pull request adds a "grid" key to the SQL meta API response, which lists all the fields we hold about each grid, keyed by the grid checksum. Like so:

```javascript
{
"databaseType": "sqlite",
"table": {
"_grids": {
"type": "table",
"columnNames": [ "url", "checksum", "title", "number" ]
}
},
"grid": {
"a7950545bec5888726b6b7fc2b054258": {
"url": "http://example.com/grid.html",
"checksum": "a7950545bec5888726b6b7fc2b054258",
"title": "My First Grid",
"number": 1
}
}
}
```

If the database in question has no `_grids` table, then the "grid" key is returned as an empty object.

Since this meta API response is also accessible via the javascript `scraperwiki.dataset.sql.meta()` function, it should save a bunch of code duplication in both server- and client-side code.