package
Garbage collection for levelup
npm install level-gcGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 15 packages.
985.2 kB
Includes dependencies.
3 direct · 3 outdated
~1.1.1
2.0.0
~1.1.10
4.8.0
~1.3.1
4.0.0
Garbage Collection for leveldb (levelup).
Scan through your level instance and cull records based on custom logic.
var util = require("util")
var level = require("level")
var db = level("/tmp/mydb")
var lts = level("/tmp/long-term-storage")
var gc = require("level-gc")
// Create a GC filter to delete all records starting with 'temp'
var re = /^temp/
var scanner = gc(db, function (record) {
// Return `true` for records you want removed.
return re.exec(record.key)
}, lts)
scanner.
gc(db, filterFn [, lts])levelup or any compliant wrapper such as level-sublevel or level-version)true for anything to be removed by the gc process. filterFn({key: key, value: value, ...})Returns an object that will let you trigger Garbage Collection runs.
If you provide the optional lts long term storage instance, as records are deleted they will be put into the lts instance.
Each run your function will be turned into a stream.Transform instance via through2-filter so you can stuff onto this and it will be available for each record in a single gc run for more complex filters.
.run([callback])Execute the gc scan. Callback is callback(err, start, end, scanned, culled).
MIT