pull-level
pull-stream interface to levelup
Example - reading
read items in database.
var pl =var pull =var db = '/tmp/pull-level-example'
read items in database, plus realtime changes
If you just want the realtime inserts,
use live
Example - writing
To write, pipe batch changes into write
If you are lazy/busy, you can leave off type
.
In that case, if value
is non-null, the change
is considered a put
else, a del
.
Example - indexes!
With pull-level it's easy to create indexes. just save a pointer to the key.
like this:
then, when you want to do a read
, use asyncMap
Example realtime aggregation
We want to keep a realtime count of everything in the database. When ever something is inserted, we increment. But, we need to check the records that are currently in the database.
Since it takes some time to scan the database, we need to make sure
we have done that before giving an answer. We can read it all with
one stream, using {sync: true}
to be notified of when we have read out all the old records.
First all the old records are read from the non-live stream,
then you get one {sync: true}
element, then all the new item.
var sum = 0 ready = false waiting =//call get count to know s{if!ready waitingelse}
License
MIT