Skip to content

Amicus/node-influx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-influx

An InfluxDB Node.js Client

Build Status Coverage Status Dependency Status

Installation

npm install influx

Usage

Create a client instance (database not required for all methods):

var influx = require('influx');
var client = influx(host, port, username, password, database);

Functions

###createDatabase Creates a new database - requires cluster admin privileges

createDatabase(databaseName, callback) { }

###deleteDatabase Deletes a database - requires cluster admin privileges

deleteDatabase(databaseName, callback) { }

###getDatabaseNames Returns array of database names - requires cluster admin privileges

getDatabaseNames(function(err,arrayDatabaseNames){}) { }

###getSeriesNames Returns array of series names from given database - requires database admin privileges

getSeriesNames(databaseName, function(err,arraySeriesNames){} ) { }

###createUser Creates a new database user - requires cluster admin privileges

createUser(databaseName, username, password, callback) { }

###updateUser Updates database user - requires cluster admin privileges

updateUser(databaseName, username, options, callback) { }

e.g.:
// adds database admin privilege
influxDB.updateUser('myDatabase','johndoe',{admin:true},callback);

###writePoint Writes a point to a series - requires database user privileges

var point = { attr : value, time : new Date()};
writePoint(seriesName, point, options, callback) { }

###writePoints Writes multiple point to a series - requires database user privileges

var points = [ {attr : value, time : new Date()}, {attr : value2, time : new Date()}];
writePoint(seriesName, points, options, callback) { }

###writeSeries Writes multiple point to multiple series - requires database user privileges

var points = [ {attr : value, time : new Date()}, {attr : value2, time : new Date()}];
var points2 = [ {attr : value, time : new Date()}, {attr : value2, time : new Date()}];

var series = {
    series_name_one : points,
    series_name_two : points2
};

writeSeries(series, options, callback) { }

Please note that there's a POST limit at about 2MB per request. Do not submit too many points at once.

###query Queries the database - requires database user privileges

var query = 'SELECT MEDIAN(column) FROM myseries WHERE time > now() - 24h';
query(query, callback) { }


query(query, callback) { }

###readPoints Reads points from a database - requires database user privileges

readPoints(query, callback) { }

*readPoints() has been replaced with query(), please upgrade *

###getContinuousQueries Fetches all continuous queries from a database - requires database admin privileges

getContinuousQueries( [databaseName,] callback) { }

###dropContinuousQuery Drops a continuous query from a database - requires database admin privileges

dropContinuousQuery( [databaseName,] queryID, callback) { }

###dropSeries Drops a series from a database - requires database admin privileges

query ( [databaseName ,] seriesName, callback) { }

As Jeff Atwood puts it... Read the source, Luke. If you're still stuck, read the ./examples/* files and the ./test.js file.

Licence

MIT

Packages

No packages published

Languages

  • JavaScript 100.0%