-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
In the later version of readable-stream (1.1 and above) there is a new write method available called ._writev that you can implement if you support batched writes (which leveldb does!). Basically it allows us to do something like this:
var ws = new stream.Writable({objectMode: true})
ws._writev = function (chunks, cb) {
// convert chunks to a leveldb batch
db.batch(batch, cb)
}
ws._write = function (data, enc, cb) {
db.put(data.key, data.value, cb)
}The _writev method will be called with all the objects currently buffered in the stream (usually the same as highWaterMark) waiting to be written. This means that all pending writes will be added to a leveldb batch.
If this is something you'd be interested in using for level-write-stream I'd be happy to send a PR
Metadata
Metadata
Assignees
Labels
No labels