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

delete a range #23

Closed
Raynos opened this issue Nov 18, 2012 · 8 comments
Closed

delete a range #23

Raynos opened this issue Nov 18, 2012 · 8 comments
Labels
enhancement New feature or request

Comments

@Raynos
Copy link
Member

Raynos commented Nov 18, 2012

Having a function for

db.del({
    start: "a"
    , end: "b"
})

Would be useful.

Use-case here is to have mechanism to purge old data mainly

db.del({
    start: "name:"
    , end: "name:someTs"
})
@Raynos
Copy link
Member Author

Raynos commented Nov 20, 2012

This should probably be a user module

@Raynos Raynos closed this as completed Nov 20, 2012
@rvagg
Copy link
Member

rvagg commented Nov 20, 2012

I'm going to reopen this because it's going to be way more efficient to do it directly against leveldb and not have to go back and forth from V8.

@rvagg rvagg reopened this Nov 20, 2012
@Raynos
Copy link
Member Author

Raynos commented Nov 20, 2012

leveldb has a direct api for this?

@rvagg
Copy link
Member

rvagg commented Nov 20, 2012

no, but it could be done directly via an iterator, totally async

@juliangruber
Copy link
Member

That's the way I went with leveled also, do all the iterator stuff directly in C

@rvagg
Copy link
Member

rvagg commented Feb 22, 2013

this needs to be done in LevelDOWN, I'd like almost identical options to those which you provide to readStream(), it's just a matter of naming. I'm not sure overloading del() is a good idea, something like delRange(), rangeDel(), delBatch() (confusing perhaps cause it wouldn't atomic in the same way batch() is). Or maybe I'm just viewing this as an implementer rather than an API user? If you think overloading del() is a good idea can you provide some code examples of how that would be done nicely without being confusing & magically implicit (always prefer explicit).

@dcousens
Copy link

dcousens commented Jan 25, 2017

Is the best way to do this using:

db.batch()
   .del(...)
   .del(...)
   .del(...)
   .del(...)
   .del(...)
   ...

?
Or is there an iterator variant without crossing the V8 boundary (ala level-delete-range)

@fergiemcdowall
Copy link

Range delete would be nice functionality, and it would also provide some symmetry with gt/gte/lt/lte in .createReadStream().

Thinking out loud here: it would be great if you could read ranges or specified keys. For example:

db.createReadStream({keys: ['id1'', 'id3', 'id16']})

db.del({keys: ['id1'', 'id3', 'id16']})

db.del({gte: 'id2', lte: 'id5'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants