Permalink
Browse files

4.5.1 - expose readStream options to data table UI

  • Loading branch information...
maxogden committed Apr 28, 2014
1 parent 21cc921 commit 895d99b004c2bfc6b3e7038e6fd19d969cc41310
Showing with 14 additions and 6 deletions.
  1. +1 −0 lib/document.js
  2. +9 −2 lib/rest-handler.js
  3. +1 −1 package.json
  4. +3 −3 test/tests/read-streams.js
View
@@ -114,6 +114,7 @@ function decodeRow(key, buff, meta, valuesOnly) {
var v = vals[i]
if (Buffer.isBuffer(v)) vals[i] = v.toString()
}
vals = [doc._id, doc._rev].concat(vals)
return vals
}
View
@@ -110,9 +110,16 @@ RestHandler.prototype.hello = function(req, res) {
RestHandler.prototype.dataTable = function(req, res) {
res.setHeader('content-type', 'text/html')
var headers = this.dat.meta.json.columns
var headers = this.dat.headers()
var reqUrl = url.parse(req.url, true)
var qs = reqUrl.query
var readOpts = {keys: false, limit: 100}
if (qs.limit) readOpts.limit = +qs.limit
if (qs.start) readOpts.start = qs.start
if (qs.end) readOpts.end = qs.end
if (qs.reverse) readOpts.reverse = Boolean(qs.reverse)
var table = dataTable(headers)
this.dat.createReadStream({keys: false, limit: 100}).pipe(table).pipe(res)
this.dat.createReadStream(readOpts).pipe(table).pipe(res)
}
RestHandler.prototype.json = function(res, json) {
View
@@ -1,6 +1,6 @@
{
"name": "dat",
"version": "4.5.0",
"version": "4.5.1",
"description": "real-time replication and versioning for large tabular data sets",
"preferGlobal": true,
"keywords": [
@@ -251,9 +251,9 @@ module.exports.createReadStreamValues = function(test, common) {
readStream.pipe(concat({encoding: 'object'}, function(rows) {
t.equal(rows.length, 5, '5 rows')
t.ok(Array.isArray(rows[0]), 'row is array, not object')
t.equal(rows[0][0], '10')
t.equal(rows[1][0], '100')
t.equal(rows[0][1], '1')
t.equal(rows[0][2], '10')
t.equal(rows[1][2], '100')
t.equal(rows[0][3], '1')
done()
}))
})

0 comments on commit 895d99b

Please sign in to comment.