Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listing conflicts (forks) #4

Closed
gmaclennan opened this issue Jan 14, 2016 · 2 comments
Closed

listing conflicts (forks) #4

gmaclennan opened this issue Jan 14, 2016 · 2 comments

Comments

@gmaclennan
Copy link
Member

Can we add an example for listing forked records? Should we add a method osm.conflicts() for this?

@ghost
Copy link

ghost commented Jan 19, 2016

This would be good to have as a method, or at least an example.

@ghost
Copy link

ghost commented Jan 27, 2016

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.

@ghost ghost closed this as completed Jan 27, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant