npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

influxdb-node

v1.0.8

Published

Node.js client for InfluxDB

Downloads

88

Readme

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