1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Update leveldb node to try to force topic to string for key.

Add extra "help" for blink1 users.
This commit is contained in:
dceejay 2015-04-14 17:23:31 +01:00
parent e56029b3e3
commit cd57346cae
5 changed files with 13 additions and 7 deletions

View File

@ -10,6 +10,10 @@ As the blink1 is a USB HID device you may need some extra hardware libraries as
documented <a href="https://www.npmjs.com/package/node-blink1" target="_new">here</a>
and <a href="https://github.com/todbot/blink1/blob/master/linux/51-blink1.rules" target="_new">here</a>.
Specifically Ubuntu/Debian/Raspbian user may need to
sudo apt-get install libusb-1.0-0.dev.
Install
-------

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-blink1",
"version" : "0.0.6",
"version" : "0.0.7",
"description" : "A Node-RED node to control a Thingm Blink(1)",
"dependencies" : {
"node-blink1" : "0.1.5"

View File

@ -48,7 +48,7 @@
<p>Uses <a href="https://code.google.com/p/leveldb/" target="_new"><i>LevelDB</i></a> for a simple key value pair database.</p>
<p>Use this node to <b>get</b>, or retrieve the data already saved in the database.</p>
<p><b>msg.topic</b> must hold the <i>key</i> for the database, and the result is returned in <b>msg.payload</b>.</p>
<p>If nothing is found for the key then <i>null</i> is returned,</p>
<p>If nothing is found for the key then <b>msg.payload</b> is set to the <i>null</i> object.</p>
</script>
<script type="text/javascript">

View File

@ -41,7 +41,8 @@ module.exports = function(RED) {
if (this.levelConfig) {
var node = this;
node.on("input", function(msg) {
if (typeof msg.topic === 'string') {
var key = msg.topic.toString();
if (key && (key.length > 0)) {
node.levelConfig.db.get(msg.topic, function(err, value) {
if (err) {
//node.warn(err);
@ -53,7 +54,7 @@ module.exports = function(RED) {
});
}
else {
if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); }
node.error("Cannot make key string from msg.topic");
}
});
}
@ -73,7 +74,8 @@ module.exports = function(RED) {
if (this.levelConfig) {
var node = this;
node.on("input", function(msg) {
if (typeof msg.topic === 'string') {
var key = msg.topic.toString();
if (key && (key.length > 0)) {
if (node.operation === "delete") {
node.levelConfig.db.del(msg.topic);
}
@ -84,7 +86,7 @@ module.exports = function(RED) {
}
}
else {
if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); }
node.error("Cannot make key string from msg.topic");
}
});
}

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-leveldb",
"version" : "0.0.1",
"version" : "0.0.2",
"description" : "A Node-RED node to read and write to a LevelDB database",
"dependencies" : {
"level" : "0.18.0"