Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-influxdb

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-influxdb - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

102

influxdb.js

@@ -17,6 +17,6 @@ var _ = require('lodash');

this.usetls = n.usetls;
if (typeof this.usetls === 'undefined'){
if (typeof this.usetls === 'undefined') {
this.usetls = false;
}
// for backward compatibility with old protocol setting
// for backward compatibility with old 'protocol' setting
if (n.protocol === 'https') {

@@ -48,2 +48,4 @@ this.usetls = true;

this.influxdb = n.influxdb;
this.precision = n.precision;
this.retentionPolicy = n.retentionPolicy;
this.influxdbConfig = RED.nodes.getNode(this.influxdb);

@@ -68,12 +70,19 @@

var measurement;
if (node.measurement) {
measurement = node.measurement;
} else {
if (msg.measurement) {
measurement = msg.measurement;
} else {
node.error(RED._("influxdb.errors.nomeasurement"),msg);
return;
}
var writeOptions = {};
var measurement = msg.hasOwnProperty('measurement') ? msg.measurement : node.measurement;
if (!measurement) {
node.error(RED._("influxdb.errors.nomeasurement"),msg);
return;
}
var precision = msg.hasOwnProperty('precision') ? msg.precision : node.precision;
var retentionPolicy = msg.hasOwnProperty('retentionPolicy') ? msg.retentionPolicy : node.retentionPolicy;
if (precision) {
writeOptions.precision = precision;
}
if (retentionPolicy) {
writeOptions.retentionPolicy = retentionPolicy;
}
// format payload to match new writePoints API

@@ -130,3 +139,4 @@ var points = [];

}
client.writePoints(points).catch(function(err) {
client.writePoints(points, writeOptions).catch(function(err) {
node.error(err,msg);

@@ -148,2 +158,4 @@ });

this.influxdb = n.influxdb;
this.precision = n.precision;
this.retentionPolicy = n.retentionPolicy;
this.influxdbConfig = RED.nodes.getNode(this.influxdb);

@@ -153,2 +165,3 @@

var node = this;
var client = new Influx.InfluxDB({

@@ -168,3 +181,15 @@ hosts: [ {

node.on("input",function(msg) {
client.writePoints(msg.payload).catch(function(err) {
var writeOptions = {};
var precision = msg.hasOwnProperty('precision') ? msg.precision : node.precision;
var retentionPolicy = msg.hasOwnProperty('retentionPolicy') ? msg.retentionPolicy : node.retentionPolicy;
if (precision) {
writeOptions.precision = precision;
}
if (retentionPolicy) {
writeOptions.retentionPolicy = retentionPolicy;
}
client.writePoints(msg.payload, writeOptions).catch(function(err) {
node.error(err,msg);

@@ -184,5 +209,8 @@ });

function InfluxInNode(n) {
RED.nodes.createNode(this,n);
RED.nodes.createNode(this, n);
this.influxdb = n.influxdb;
this.query = n.query;
this.precision = n.precision;
this.retentionPolicy = n.retentionPolicy;
this.rawOutput = n.rawOutput;
this.influxdbConfig = RED.nodes.getNode(this.influxdb);

@@ -192,3 +220,3 @@ if (this.influxdbConfig) {

var client = new Influx.InfluxDB({
hosts: [ {
hosts: [{
host: this.influxdbConfig.hostname,

@@ -198,3 +226,3 @@ port: this.influxdbConfig.port,

options: this.influxdbConfig.hostOptions
}
}
],

@@ -205,19 +233,37 @@ database: this.influxdbConfig.database,

});
node.on("input",function(msg) {
node.on("input", function (msg) {
var query;
if (node.query) {
query = node.query;
var rawOutput;
var queryOptions = {};
var precision;
var retentionPolicy;
query = msg.hasOwnProperty('query') ? msg.query : node.query;
if (!query) {
node.error(RED._("influxdb.errors.noquery"), msg);
return;
}
if (!node.query) {
if (msg.query) {
query = msg.query;
} else {
node.error(RED._("influxdb.errors.noquery"),msg);
return;
}
rawOutput = msg.hasOwnProperty('rawOutput') ? msg.rawOutput : node.rawOutput;
precision = msg.hasOwnProperty('precision') ? msg.precision : node.precision;
retentionPolicy = msg.hasOwnProperty('retentionPolicy') ? msg.retentionPolicy : node.retentionPolicy;
if (precision) {
queryOptions.precision = precision;
}
client.query(query).then(function(results) {
if (retentionPolicy) {
queryOptions.retentionPolicy = retentionPolicy;
}
if (rawOutput) {
var queryPromise = client.queryRaw(query, queryOptions);
} else {
var queryPromise = client.query(query, queryOptions);
}
queryPromise.then(function (results) {
msg.payload = results;
node.send(msg);
}).catch(function(err) {
}).catch(function (err) {
node.error(err);

@@ -224,0 +270,0 @@ });

@@ -11,3 +11,7 @@ {

"use-tls": "Enable secure (SSL/TLS) connection",
"tls-config":"TLS Configuration"
"tls-config":"TLS Configuration",
"use-raw-output":"Raw Output",
"time-precision":"Time Precision",
"retention-policy":"Retention Policy",
"use-advanced-query":"Advanced Query Options"
},

@@ -14,0 +18,0 @@ "errors":{

{
"name": "node-red-contrib-influxdb",
"version": "0.1.1",
"version": "0.2.0",
"description": "Node-RED nodes to save and query data from an influxdb time series database",

@@ -19,8 +19,8 @@ "main": "influxdb.js",

"license": "Apache-2.0",
"keywords":[
"keywords": [
"node-red",
"influxdb"
],
"node-red" : {
"nodes" : {
"node-red": {
"nodes": {
"influxdb": "influxdb.js"

@@ -30,5 +30,5 @@ }

"dependencies": {
"influx": "5.0.6",
"influx": "5.0.7",
"lodash": "^3.10.0"
}
}

@@ -10,3 +10,3 @@ node-red-contrib-influxdb

To run this you'll need access to an influxdb database version 1.1.x, possibly later. See the <a href="https://influxdb.com/" target="_new">influxdb site</a> for more information. The last release of this node has been tested with InfluxDb 1.1.1.
To run this you'll need access to an influxdb database version 1.1.x, possibly later. See the <a href="https://influxdb.com/" target="_new">influxdb site</a> for more information. The last release of this node has been tested with InfluxDb 1.2.4.

@@ -13,0 +13,0 @@ Install

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc