Comments (10)
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.
Clearing works the same as iterating (it visits the same keys). Should we forego that symmetry?
from subleveldown.
probably not, but perhaps adding an option field? something like "all" to signal you want to clear everything?
from subleveldown.
That might be nice for iterators too.
from subleveldown.
something like "all"
Or "deep". A PR is welcome.
from subleveldown.
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.
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.
I fail to replicate #85 (comment).
from subleveldown.
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.
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)
- How to get the exception `Inner database is not open`? HOT 2
- Support buffer/Uint8Array prefixes HOT 7
- A way to get a deeply nested sublevel in one-go HOT 5
- Release v3.0.0 HOT 1
- Streams are ignoring fillCache option HOT 2
- Segfault with subleveldown HOT 27
- bytewise key-encoding on sub-level causes not found on other level HOT 20
- Adding _seek to SubIterator HOT 4
- Disable `clear()` HOT 2
- Take advantage of manifests and the squash down HOT 1
- An in-range update of abstract-leveldown is breaking the build 🚨 HOT 3
- Applies prefix twice on nested sublevel HOT 12
- An in-range update of levelup is breaking the build 🚨 HOT 2
- Remove unnecessary condition HOT 1
- Drop support of memdb
- Require deferredOpen support HOT 1
- Possible issue with buffer keys HOT 10
- Decoder Err ! HOT 3
- Should the `createReadStream` method be scoped to the subs? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from subleveldown.