Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support v2 write #2

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node-version: [8.x, 10.x, 12.x, 14.x]
node-version: [12.x, 14.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm test
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# influxdb-v1
# influxdb-lite

A light-weight library to write data to InfluxDB.

Expand All @@ -7,8 +7,10 @@ A light-weight library to write data to InfluxDB.

## Example

### Influx DB v1

```javascript
const influx = require('influxdb-v1');
const influx = require('influxdb-lite');

await influx.write(
{
Expand Down Expand Up @@ -52,12 +54,47 @@ await db.query('SELECT * FROM measurement');
await db.flux('from(bucket:"telegraf")');
```

### Influx DB v2

```javascript
const influx = require('influxdb-lite');

await influx.write(
{
url: 'http://influx.url',
version: 'v2',
bucket: 'bucket name',
org: 'org',
token: 'token',
},
[
{
measurement: 'web',
fields: {
load: 12.34
}
},
{
measurement: 'web',
fields: {
load: 5.4
},
tags: {
host: 'linux'
},
timestamp: Date.now()
}
]
);
```


## CLI

### Insert Data

```shell
npx influxdb-v1 insert --url <influx-base-url> --username <user> --password <pass> --db <database> --measurement <measurement> --tags "key=value" --fields "key=value" --ts <timestamp>
npx influxdb-lite insert --url <influx-base-url> --username <user> --password <pass> --db <database> --measurement <measurement> --tags "key=value" --fields "key=value" --ts <timestamp>
```

### Note
Expand Down
Loading
Loading