'gt' (greater than), 'gte' (greater than or equal) define the lower bound of the range to be streamed. Only records where the key is greater than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.

'lt' (less than), 'lte' (less than or equal) define the higher bound of the range to be streamed. Only key/value pairs where the key is less than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.

'start', 'end' legacy ranges - instead use 'gte', 'lte'

'match'(string): use the minmatch to match the specified keys.

Note: It will affect the range[gt/gte or lt/lte(reverse)] options maybe.

'limit'(number, default: -1): limit the number of results collected by this stream. This number represents a maximum number of results and may not be reached if you get to the end of the data first. A value of -1 means there is no limit. When reverse=true the highest keys will be returned instead of the lowest keys.

'reverse'(boolean, default: false): a boolean, set true and the stream output will be reversed.

'keys'(boolean, default: true): whether the 'data' event should contain keys. If set to true and 'values' set to false then 'data' events will simply be keys, rather than objects with a 'key' property.

'values'(boolean, default: true): whether the 'data' event should contain values. If set to true and 'keys' set to false then 'data' events will simply be values, rather than objects with a 'value' property.

return

object: the read stream object

the standard 'data', 'error', 'end' and 'close' events are emitted.
the 'last' event will be emitted when the last data arrived, the argument is the last raw key(no decoded).
if no more data the last key is undefined.

Examples

filter usage:

db.createReadStream({filter:function(key,value){

if(/^hit/.test(key))

returndb.FILTER_INCLUDED

else key =='endStream'

returndb.FILTER_STOPPED

else

returndb.FILTER_EXCLUDED

}})

.on('data',function(data){

console.log(data.key,'=',data.value)

})

.on('error',function(err){

console.log('Oh my!', err)

})

.on('close',function(){

console.log('Stream closed')

})

.on('end',function(){

console.log('Stream closed')

})

next and last usage for paged data demo:

var callbackStream =require('callback-stream')

var lastKey =null;

functionnextPage(db,aLastKey,aPageSize,cb){

var stream =db.readStream({next: aLastKey, limit: aPageSize})

stream.on('last',function(aLastKey){

lastKey = aLastKey;

});

stream.pipe(callbackStream(function(err,data){

cb(data, lastKey)

}))

}

var pageNo =1;

dataCallback=function(data,lastKey){

console.log("page:", pageNo);

console.log(data);

++pageNo;

if(lastKey){

nextPage(db, lastKey,10, dataCallback);

}

else

console.log("no more data");

}

nextPage(db, lastKey,10, dataCallback);

Hooks

Hooks are specially built into Sublevel so that you can
do all sorts of clever stuff, like generating views or
logs when records are inserted!

Records added via hooks will be atomically inserted with the triggering change.