Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/blobs-put.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ module.exports = function(dat, opts, cb) {
row = existing
}
var blobKey = opts.name || path.basename(blob)
var ws = dat.createBlobWriteStream(blobKey, row, function(err, updated) {
var options = { filename:blobKey, version:version }

var ws = dat.createBlobWriteStream(options, row, function(err, updated) {
if (err) return cb(err)
console.log('Attached ' + blobKey + ' successfully to', updated.key)
console.log('Attached ' + options.filename + ' successfully to', updated.key)
cb()
})

Expand Down
2 changes: 1 addition & 1 deletion bin/rows-put.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ module.exports = function (dat, opts, cb) {
cb()
})
}
}
}
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ function close() {
} else {
dat.close()
}
}
}
16 changes: 10 additions & 6 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,16 @@ dat.createBlobWriteStream = function(options, doc, cb) {
if (!cb) cb = noop

debug('createBlobWriteStream', options.filename)
var version = doc.version
if (!doc.version && options.version) {
version = options.version
}

var blobWrite = this.blobs.createWriteStream(options, function(err, blob) {
if (err) return cb(err)
if (!doc.blobs) doc.blobs = {}
doc.blobs[options.filename] = blob
self.put(doc, {version:doc.version}, cb)
self.put(doc, {version:options.version}, cb)
})

return blobWrite
Expand Down Expand Up @@ -783,10 +787,10 @@ dat.put = function(key, doc, opts, cb) {

var ready = function(err, doc) {
if (err) return cb(err)

self.storage.put(key, isBuffer ? doc : self.schema.encode(doc), {version:version, force:opts.force}, function(err, value, version) {
self.storage.put(key, isBuffer ? doc : self.schema.encode(doc), {version:version, force:opts.force}, function(err, value, version, change) {
if (err) return cb(err)
cb(null, self.schema.decode(value, {key:key, version:version}))
cb(null, self.schema.decode(value, {key:key, version:version, change:change}))
})
}

Expand All @@ -805,9 +809,9 @@ dat.get = function(key, opts, cb) {

var self = this

this.storage.get(key, opts, function(err, value, version) {
this.storage.get(key, opts, function(err, value, version, change) {
if (err) return cb(err)
var val = self.schema.decode(value, {key:key, version:version, blobsOnly:opts.blobsOnly})
var val = self.schema.decode(value, {key:key, version:version, change:change, blobsOnly:opts.blobsOnly})
if (self.afterGet) self.afterGet(val, cb)
else cb(null, val)
})
Expand Down
3 changes: 2 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Schema.prototype.decode = function(buf, opts) {
var msg = this.messages.Row.decode(buf)
msg.key = opts.key
msg.version = opts.version
msg.change = opts.change
return msg
}

Expand Down Expand Up @@ -203,4 +204,4 @@ Schema.prototype._tag = function() {
return 1 + this.fields.map(toTag).reduce(max, 0)
}

module.exports = Schema
module.exports = Schema
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dat",
"version": "6.8.1",
"version": "6.9.0",
"description": "real-time replication and versioning for data sets (tabular and blobs)",
"preferGlobal": true,
"keywords": [
Expand Down Expand Up @@ -52,7 +52,7 @@
"isnumber": "^1.0.0",
"json-protobuf-encoding": "^1.0.1",
"ldjson-stream": "~1.0.0",
"level-dat": "^4.4.1",
"level-dat": "^4.5.0",
"level-events": "^1.0.2",
"level-js": "^2.1.3",
"level-manifest": "~1.2.0",
Expand Down