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

Should the createReadStream method be scoped to the subs? #94

Closed
theprojectsomething opened this issue Nov 1, 2020 · 3 comments
Closed

Comments

@theprojectsomething
Copy link

The readme example explaining how sub dbs "are just regular levelup instances" is a bit ambiguous, in that it also seems to suggest that the createReadStream method is scoped to the sub:

var sub = require('subleveldown')
var level = require('level')

var db = level('db')
var example = sub(db, 'example')
var nested = sub(example, 'nested')

The example and nested db's are just regular levelup instances:

example.put('hello', 'world', function () {
  nested.put('hi', 'welt', function () {
    // will print {key:'hello', value:'world'}
    example.createReadStream().on('data', console.log)
  })
})

Except this doesn't appear to be the case. The above example actually prints:

{ key: '!nested!hi', value: 'welt' }
{ key: 'hello', value: 'world' }

Is this intentional?

@vweevers
Copy link
Member

vweevers commented Nov 1, 2020

Aye, sub.createReadStream() yields the entries of itself and any nested sublevels (because they are part of sub). Similar to how db.createReadStream() yields all entries.

@theprojectsomething
Copy link
Author

Just my two cents but feels like this is the only feature that feels a bit cumbersome (but easy to work around!). Either way, IMO its worth updating the readme so the example shows the correct output, if only to save rookies like myself scratching a hole in their head. Happy to make a PR if that helps.

@vweevers
Copy link
Member

vweevers commented Nov 1, 2020

Either way, IMO its worth updating the readme so the example shows the correct output, if only to save rookies like myself scratching a hole in their head.

Agree!

Happy to make a PR if that helps.

👍

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

2 participants