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

node-tsguru

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-tsguru

TimeSeries.Guru Node.js client

  • 1.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status NPM version NPM dependencies

node-tsguru

TimeSeries.Guru Node.js client.

Installation

npm install node-tsguru

Demos

Demo applications are available at:

Usage

Callback style

Create client
var tsguru = require("node-tsguru");
tsguru({token: "abc123456789def", databaseID: "abc123456789def"}, function(err, client) {
	if (err) throw err;
	console.log("connected");
	// interact with client like demonstrated below
});
Insert single value (simple time series with one column)
client.insert("sensor01", 123.45, function(err) {
	if (err) throw err;
	console.log("inserted");
});
Insert single value (simple time series with two columns)
client.insert("sensor01", 123.45, 100, function(err) {
	if (err) throw err;
	console.log("inserted");
});
Insert single value (symbol time series with one column)
client.insertSymbol("sensor", "sen01", 123.45, function(err) {
	if (err) throw err;
	console.log("inserted");
});
Insert single value (symbol time series with three columns)
client.insertSymbol("sensor", "sen01", 123.45, 10, true, function(err) {
	if (err) throw err;
	console.log("inserted");
});
Insert multiple values
client.bulk()
	.add("sensor01", 123.45)
	.add("sensor02", 234.56)
	.add("sensor03", 345.67)
	.add("sensor04", 456.78)
	.insert(function(err) {
		if (err) throw err;
		console.log("bulk inserted");
	});
Buffer values
var buffer = client.buffer({delay: 250});
buffer.on("error", function(err) {
	throw err;
});
buffer.on("flushed", function() {
	console.log("flushed");
});
setInterval(function() {
	buffer.add("sensor01", 123.45);
}, 100);

buffer() returns an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter). Emitted events are error, flush and flushed.

Promise style

Create client
var tsguru = require("node-tsguru");
tsguru({token: "abc123456789def", databaseID: "abc123456789def"})
	.then(function(client) {
		console.log("connected");
		// interact with client like demonstrated below
	})
	.catch(function(err) {
		console.log(err);
	});
Insert single value
client.insert("sensor01", 123.45)
	.then(function(client) {
		console.log("inserted");
	})
	.catch(function(err) {
		console.log(err);
	});
Insert multiple values
client.bulk()
	.add("sensor01", 123.45)
	.add("sensor02", 234.56)
	.add("sensor03", 345.67)
	.add("sensor04", 456.78)
	.insert()
		.then(function(client) {
			console.log("bulk inserted");
		})
		.catch(function(err) {
			console.log(err);
		});

API

(params[, cb])

  • params: Object
    • token: String
    • databaseID: String
    • timeout: Number in milliseconds (optional, default: 10000)
  • cb: Function(err, client) (optional)
    • err: Error or undefined
    • client: Client or undefined

returns a Promise if no cb was supplied

Client

Client is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter).

insert(timeseriesName, value1[, value2[, ...]][, cb])

Insert into a simple time series.

  • timeseriesName: String
  • value1 ... valueN: Number, Boolean or String
  • cb: Function(err) (optional)
    • err: Error or undefined

returns a Promise if no cb was supplied

insertSymbol(timeseriesName, symbol, value1[, value2[, ...]][, cb])

Insert into a symbol time series.

  • timeseriesName: String
  • symbol: String
  • value1 ... valueN: Number, Boolean or String
  • cb: Function(err) (optional)
    • err: Error or undefined

returns a Promise if no cb was supplied

bulk()

returns a Bulk

Bulk
add(timeseriesName, value1[, value2[, ...]])

Add to a simple time series.

  • timeseriesName: String
  • value1 ... valueN: Number, Boolean or String
addSymbol(timeseriesName, symbol, value1[, value2[, ...]])

Add to a symbol time series.

  • timeseriesName: String
  • symbol: String
  • value1 ... valueN: Number, Boolean or String
insert([cb])

Insert takes care about maximal allowed body size. A single insert can be split into multiple POST calls if the HTTP body gets to large.

  • cb: Function(err) (optional)
    • err: Error or undefined

returns a Promise if no cb was supplied

buffer(params)
  • params: Object
    • delay: Number - delay in milliseconds

returns a Buffer

Buffer
add(timeseriesName, value1[, value2[, ...]])

Add to a simple time series.

  • timeseriesName: String
  • value1 ... valueN: Number, Boolean or String
addSymbol(timeseriesName, symbol, value1[, value2[, ...]])

Add to a symbol time series.

  • timeseriesName: String
  • symbol: String
  • value1 ... valueN: Number, Boolean or String
close([cb])

Flush the buffer and stop the interval timer. No more adds after close!

  • cb: Function(err) (optional)
    • err: Error or undefined

returns a Promise if no cb was supplied

Keywords

FAQs

Package last updated on 21 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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