Scanning

This page walks through the RESTful API for scanning by using curl.

Prerequisites

If you haven’t already, setup a server, and then add some data.

Scan the Latest

To scan the most recent values of the whole table, GET just /<table>.

curl -i -w'\n' http://localhost:7070/fruit
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

[ {"key": "apple", "time": 1436030718013001, "value": "granny smith"},
  {"key": "grape", "time": 1436030718013001, "value": "cabernet"} ]

Scan a Snapshot

You can use until to scan a past snapshot of the table:

curl -i -w'\n' http://localhost:7070/fruit?until=1436030359000000
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

[ {"key": "apple", "time": 1436030358171001, "value": "sour"} ]

Like the TxClock headers in GET and PUT, until represents microseconds since the Unix epoch. You could use the Value-TxClcok from a PUT for until in a scan, and see the snapshot that contains the results of that PUT.

TreodeDB keeps snapshots to midnight of the previous day.

Scan a Duration

You can use since, until and pick see all changes over a window of time:

curl -i -w'\n' 'http://localhost:7070/fruit?since=1436030359000000&until=1436030719000000&pick=between'
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

[ {"key": "apple", "time": 1436030718013001, "value": "granny smith"},
  {"key": "apple", "time": 1436030453060001, "value": "green"},
  {"key": "grape", "time": 1436030718013001, "value": "cabernet"} ]

The since parameter defaults to time 0. The until parameter defaults the current time. And the pick parameter defaults to latest.

TreodeDB keeps historical writes to midnight of yesterday. TreodeDB always keeps the latest write, even if that occurred prior midnight of yesterday. But overwritten writes it keeps only until midnight of yesterday.

Scan a Range

With key and end, you can limit the scan to a range of keys.

curl -i -w'\n' 'http://localhost:7070/fruit?key=a&end=d'
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

[ {"key": "apple", "time": 1436030718013001, "value": "granny smith"} ]

curl -i -w'\n' 'http://localhost:7070/fruit?key=e&end=h'
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked

[ {"key": "grape", "time": 1436030718013001, "value": "cabernet"} ]

The scan begins at key inclusive and stops before end exclusive.

Scan a Page

Use limit to scan only that many rows; the response reveals the beginning of the next page in the Link header. We have very few rows in this database, so we will use a very low limit.

curl -i -w'\n' http://localhost:7070/fruit?limit=1
HTTP/1.1 200 OK
Link: <http://localhost:7070/fruit?key=grape&time=1436744628483001&limit=1>; rel="next"
Content-Type: application/json
Content-Length: 64

[ {"key": "apple", "time": 1436030718013001, "value": "granny smith"} ]

TreodeDB provides the URL for the next request in the Link header. That scan will begin at key and time inclusive.