Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kyya authored Oct 5, 2021
1 parent a3b5199 commit ad57674
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# json2flux
A tool for converting json to flux query.


## Getting startted
```js
import json2flux from '@tuxmart/json2flux';



const jsonString = `
{
"bucket": "mainflux_1h",
"range": "-7d",
"filters": [
{
"key": "building",
"value": "mock-building",
"operator": "eq"
},
{
"key": "_measurement",
"value": "CO2",
"operator": "eq"
},
{
"key": "device",
"value": "Air-Quality-Sensor",
"operator": "eq"
},
{
"key": "_field",
"value": "value",
"operator": "eq"
}
]
}
`;

json2flux(jsonString);
```


It will be converted into influx query.

```js
from(bucket: "mainflux_1h")
|> range(start: -7d)
|> filter(fn: (r) => r["building"] == "mock-building")
|> filter(fn: (r) => r["_measurement"] == "CO2")
|> filter(fn: (r) => r["device"] == "Air-Quality-Sensor")
|> filter(fn: (r) => r["_field"] == "value")
```

0 comments on commit ad57674

Please sign in to comment.