Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »


0.0.3 • Public • Published

06 Oct 2015 - node-red-contrib-leveldb-ttl


Run the following command in the root directory of your Node-RED install

npm install node-red-contrib-leveldb-ttl


npm install git://


This is a quick and dirty Node-RED package to add Level-ttl support to the original node-red-node-leveldb code (version 0.0.5), and to wrap some Levelup functions, like batch and streams.

Use one node to either put (store) the msg.payload to the named database file, using msg.topic as the key, or to delete information select delete in the properties dialogue and again use msg.topic as the key..

Use the other node to get, or retrieve the data already saved in the database.

Again use msg.topic to hold the key for the database, and the result is returned in msg.payload. If nothing is found for the key then null is returned.

The configuration node allows to set the database Default TTLin seconds (0: disabled), and Scan TTL to set the internal scan in seconds. The Default TTL can be overriden.

The node to get from the database works as the original.

Some info about the new nodes:

Stream node: The configuration of this node defines the default type of stream: ReadStream, KeyStream or ValueStream. This can be overriden using msg.payload.keys and msg.payload.values. The range of keys that are streamed can be set by using msg.payload.start, msg.payload.end,, or msg.payload.limit. If no options are passed, it streams the entire database. Example: msg.payload = { keys: true, values: false, start: 'key1~', end: 'key1~~' } Stream2 node: it returns all results in one message.

Batch node: can be used for very fast bulk-write operations (both put and delete). msg.payload should contain a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside LevelDB. Example: msg.payload =[ {type: 'put', key: 'key1', value: 123}, {type: 'del', key: 'key2'} ]

Batch2 node: This node get individuals operations and push them in a buffer before doing the batch operation to the database. The configuration of this node allows to set the buffer size.

KeyTTL node: This node can serve to insert or update a ttl for any given key from msg.topic in the database (even if that key doesn't exist but may in the future).

The configuration of the nodes to put, to batch and the keyttl node, include a Node TTL parameter to override the Default TTL. Also, Node TTL can be individually overriden by a msg.ttl.


npm i node-red-contrib-leveldb-ttl

Downloadsweekly downloads









last publish


  • avatar
Report a vulnerability