level-stream-access
Write and read stream values from leveldb database
Installation
Install level-stream-access from npm. You also need levelup to be installed.
npm install level-stream-access level
Setup
Create a level-stream-access instance by providing a levelup object that is used for storage.
const levelup = ;const levelStreamAccess = ;const levelStream = ;
createWriteStream()
Write a large stream into leveldb database
let writer = levelStream;
Example
fs ;
createReadStream()
Read a stream from leveldb database
let reader = levelStream;
Example
levelStream ;
createStoreStream()
Write a large stream into leveldb database and immediatelly read the stored data. Use it if you want to pass on data but you need to make sure that data gets stored.
let store = levelStream;
Example
fs ;
prepend()
Prepend data to the beginning of the stored stream. This is mostly useful if the stream is an email message and you want to add new headers to it
levelStream;
Where
- keyname is the stream key to prepend data to
- value is a Buffer or string data to be prepended to the stream
- callback is the function to run once data is prepended
Example
levelStream;
setMeta()
Attach JSON metadata to the stored stream. This value gets removed when you delete the stream. If there already was metadata set, it gets overwritten. If the stream does not exists, then metadata is not stored and callback returns false, otherwise it returns true
levelStream;
Where
- keyname is the stream key to add metadata to
- data is an object that can be converted to JSON
- callback is the function to run once data is stored
Example
levelStream;
getMeta()
Get JSON metadata for the stored stream. This value combines both the user defined metadata
using setMeta
and system metadata (eg. created
with creation timestamp).
levelStream;
Where
- keyname is the stream key to get metadata for
- callback is the function to run once data is stored
Example
levelStream;
delete()
Delete streamed data from leveldb
levelStream;
Example
levelStream;
License
MIT