Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Why is sublevel molesting my primary entries? #63

Open
rvagg opened this issue Aug 18, 2014 · 4 comments
Open

Why is sublevel molesting my primary entries? #63

rvagg opened this issue Aug 18, 2014 · 4 comments

Comments

@rvagg
Copy link
Contributor

rvagg commented Aug 18, 2014

var _db = require('level')('wut.db')
var db = require('level-sublevel')(_db)
db.put('foo', 'bar', function () {
  _db.put('boom', 'bang', function () {
    _db.close(function () {
      db = require('level')('wut.db')
      db.createReadStream().on('data', console.log)
    })
  })
})

Results in:

{ key: '!!foo', value: 'bar' }
{ key: 'boom', value: 'bang' }

Unexpected and unfortunate given the pattern we've evolved of db = sublevel(db). Or is this intentional now?

@calvinmetcalf
Copy link

I interpret this comment by dominic to say that this is intentional, just noticed this myself.

@rvagg rvagg closed this as completed Aug 18, 2014
@dominictarr
Copy link
Owner

since v5 sublevel returns a new object, it's not the leveldb object.
in v6 sublevel uses a different prefixing pattern and you won't be able to see any _db.put data from db.
That is for simplicity of how the prefixes are structured. what keys would you expect?

@rvagg
Copy link
Contributor Author

rvagg commented Aug 19, 2014

It's the fact that it's not a levelup object any more that's making sublevel much less useful for what I need, it's unpredictable and I'm finding lots of edge cases and I can't just treat it like a levelup like I used to. I know the use-cases are being expanded here but I don't tend to have a need for them, I just need a namespacing tool that's simple and predictable.

@dominictarr
Copy link
Owner

hmm, I guess you can't please everyone:
#25

It would be helpful to know what edgecases you are encountering.
if you use require('sublevel/legacy') it will use a prefixing system that is compatible with 5.
does that work for you?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants