Skip to content

Commit

Permalink
Store an optional value on deletions.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergrrl committed Jul 12, 2017
1 parent 784183e commit 32feebb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function DB (opts) {
map: function (row, next) {
if (!row.value) return null
var v = row.value.v, d = row.value.d
if (v && v.lat !== undefined && v.lon !== undefined) {
var k = row.value.k
if (k && v.lat !== undefined && v.lon !== undefined) {
next(null, { type: 'put', point: ptf(v) })
} else if (d && Array.isArray(row.value.points)) {
var pts = row.value.points.map(ptf)
Expand Down Expand Up @@ -264,7 +265,15 @@ DB.prototype._getDocumentDeletionBatchOps = function (id, opts, cb) {
fields.members.push.apply(fields.members, v.members)
}
})
cb(null, [ { type: 'del', key: id, links: links, fields: fields } ])

// Use opts.value to set a value on hyperkv deletions.
if (opts.value) {
fields = xtend(fields, {
v: opts.value
})
}

cb(null, [ { type: 'del', key: key, links: links, fields: fields } ])
}
}

Expand Down

0 comments on commit 32feebb

Please sign in to comment.