New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

influxdb-node

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

influxdb-node

Node.js client for InfluxDB

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

InfluxDB Javascript Client

This repository contains the javascript client of the InfluxDB time series database server from InfluxData. This client is officially supported by InfluxData.

The documentation here only covers the client API in Javascript. For more information about the InfluxDB server please consult the server documentation.

Quick Install

To quickly add the InfluxDB javascript client to your Node.js project:

$ npm install --save influxdb-nodejs

Overview

A full featured client written in ECMAScript 2015.

  • Supports write batching and query result post-processing
  • Supports Node.js 0.10 and later (note that all the examples are written using ES6 which is supported by Node.js natively since version 4)
  • Provides easy access to the core InfluxDB API.

Setup

You may check the reference documentation as well.

Connect to a database

    const InfluxDB = require('influxdb-node');

    const connection = new InfluxDB.Connection({
        hostUrl: 'http://localhost:8086',
        database: 'mydb'
    });

    // the connect call below is optional; if you won't do it, connection
    // will be initiated on the first read/write from/to InfluxDB
    connection.connect().then(() => {
       console.log('Connection established successfully');
    }).catch((e) => {
       console.error('Unexpected Error',e);
    });

Write to a database

    const dataPoint1 = {
        measurement : 'outdoorThermometer',
        timestamp: new Date(),
        tags: {
            location: 'greenhouse'
        },
        fields: { temperature: 23.7 }
    };

    // you can also provide tag and field data as arrays of objects:
    const dataPoint2 = {
        measurement : 'outdoorThermometer',
        timestamp: new Date().getTime()+1000000,
        tags: [ 
            { 
                key: 'location', 
                value: 'outdoor' 
            }
        ],
        fields: [ 
            { 
                key: 'temperature', 
                value: 23.7 
            } 
        ]
    };

    const series = [dataPoint1, dataPoint2];
    connection.write(series).catch(console.error);
    
    // if you need to, you may enforce emptying write buffers between
    // your application and InfluxDB
    connection.flush().then(() => {
        console.log('Data written into InfluxDB')
    }).catch(console.error);

Read from a database

    connection.executeQuery('select * from outdoorThermometer group by location').then((result) => {
        console.log(result);
    }).catch(console.error);

Drop data from a database

    let connection = new InfluxDB.Connection({
        hostUrl: 'http://localhost:8086',
        database: 'mydb'
    });

    connection.executeQuery('drop measurement outdoorThermometer').then(() => {
      console.log('Measurement dropped');
    }).catch(console.error);

Releases

  • Version 1.0.0 - Initial release

Keywords

influxdb

FAQs

Package last updated on 25 Jul 2018

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