Coder Social home page Coder Social logo

Comments (10)

MeirionHughes avatar MeirionHughes commented on May 27, 2024

okay, actually tested it; doesn't seem to:

  let db = levelup(encoding(memdown()));

  let dbsub = sub(db, "foo");
  let dbsubsub = sub(dbsub, "bar");

  await dbsub.put("A", "a");
  await dbsubsub.put("B", "b");

  await dumpKeys(db);

  await dbsub.clear();

  await dumpKeys(db);
DUMP:
 !foo!!bar!B
 !foo!A
DUMP:
 !foo!!bar!B

I guess I can work around it with something like: await db.clear({gte: "!foo!", lt: "!foo$"})

from subleveldown.

vweevers avatar vweevers commented on May 27, 2024

Clearing works the same as iterating (it visits the same keys). Should we forego that symmetry?

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 27, 2024

probably not, but perhaps adding an option field? something like "all" to signal you want to clear everything?

from subleveldown.

vweevers avatar vweevers commented on May 27, 2024

That might be nice for iterators too.

from subleveldown.

vweevers avatar vweevers commented on May 27, 2024

something like "all"

Or "deep". A PR is welcome.

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 27, 2024

but what would be the range?
{gte: prefix, lt: prefix.substring(0, prefix.length - 1) + "$"}?.

I just guessed that lt: ...$ would be the catch all - not sure if that is valid/safe?

from subleveldown.

vweevers avatar vweevers commented on May 27, 2024

Looking more closely at this, iterators already include the keys of nested sublevels. Maybe you were hitting a race issue in opening the db?

from subleveldown.

vweevers avatar vweevers commented on May 27, 2024

I fail to replicate #85 (comment).

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 27, 2024

you're right; looks like the issue only arises when encoding-down is used - I tried to replicate in existing (subleveldown) test but couldn't, but it is only db = levelup(memdown)

if I remove encoding-down from the code above, it clears properly.

... and I've tried to test that too (var down = encoding(memdown())) in the main test file and can't replicate. no idea what is going on now...

from subleveldown.

MeirionHughes avatar MeirionHughes commented on May 27, 2024

dam... I think it might have been a bad version on my monorepo. I forced update to the latest versions and the issue seems to have vanished. Sorry... I thought had updated them all - but I think I had the last memdown major - sorry for wasting your time.

from subleveldown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.