You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
51 lines
1.0 KiB
const Influx = require('influx')
|
|
|
|
module.exports = function init () {
|
|
const influx = new Influx.InfluxDB({
|
|
host: process.env.INFLUX_HOST || '172.18.0.1',
|
|
database: process.env.INFLUX_DATABASE || 'dummy-data',
|
|
schema: [
|
|
{
|
|
measurement: 'temperature',
|
|
fields: {
|
|
value: Influx.FieldType.INTEGER
|
|
},
|
|
tags: [
|
|
'deviceId'
|
|
]
|
|
},
|
|
{
|
|
measurement: 'air_humidity',
|
|
fields: {
|
|
value: Influx.FieldType.INTEGER
|
|
},
|
|
tags: [
|
|
'deviceId'
|
|
]
|
|
},
|
|
{
|
|
measurement: 'ground_humidity',
|
|
fields: {
|
|
value: Influx.FieldType.INTEGER
|
|
},
|
|
tags: [
|
|
'deviceId'
|
|
]
|
|
},
|
|
{
|
|
measurement: 'airforce',
|
|
fields: {
|
|
value: Influx.FieldType.INTEGER
|
|
},
|
|
tags: [
|
|
'deviceId'
|
|
]
|
|
}
|
|
]
|
|
})
|
|
influx.createDatabase(process.env.INFLUX_DATABASE)
|
|
.catch(console.error)
|
|
|
|
return influx
|
|
}
|
|
|
|
|