Closed gmaclennan closed 8 years ago
This would be good to have as a method, or at least an example.
I added an example in test/fork_count.js
:
var hyperlog = require('hyperlog')
var fdstore = require('fd-chunk-store')
var level = require('level')
var db = level('/tmp/whatever.db')
var logdb = level('/tmp/whatever.log')
var osmdb = require('../')
var osm = osmdb({
log: hyperlog(logdb, { valueEncoding: 'json' }),
db: db,
store: fdstore(4096, '/tmp/whatever.store')
})
osm.kv.createReadStream({ values: false })
.on('data', function (row) {
console.log(row.key, row.links.length)
})
hyperkv has a createReadStream()
method to list all the active keys, and row.links
contains an array of all the forks of that key. When row.links.length > 1
, there exists more than one version of a document. I've also added this use-case to the test suite and documented osm.kv
.
Can we add an example for listing forked records? Should we add a method
osm.conflicts()
for this?