mblackstock / node-red-contrib-influxdb

Node-RED nodes to save and query data from an influxdb time series database
Other
64 stars 44 forks source link

add simple schema editor for output validation and encoding of numeric types #118

Open mblackstock opened 2 years ago

mblackstock commented 2 years ago

Currently all numbers are sent as float, and integers are encoded as a string, which is a bit odd. We need a way to specify the numeric types of fields in a more consistent and flexible way. This could be generalized to specify the type of each named field in a point for consistency.

One way to do this might be to have a schema editor in the output node that optionally specifies the types of fields in a message by name (boolean, int, uint, float, string). Under the hood this editor could use JSON schema in the configuration.

The output node could have a 'use schema' checkbox, and then you create a list of name/types. When a message is sent to the output node, it would ensure that the correct schema is used, and reject messages that it cannot convert. If a schema is not specified, a default encoding could be used - all numbers are float, strings, booleans sent as is.