Skip to main content

Concepts

Concepts for the JavaScript transform method

The "javascript" transform method runs JavaScript code to modify incoming data. After you create JavaScript code and assign it to a table, FairCom Edge runs it each time any process inserts a record into the table, such as FairCom connectors retrieving data from devices, MQTT clients publishing messages, and SQL or JSON DB API inserting records.

Your JavaScript code has full access to the data in the record and can write transformed data to any field in the record except the source_payload field and fields previously written to by other transform steps. A single JavaScript transform can write different results to many fields.

Examples
  • Recalculate data by running calculations on the data, such as calculating overall equipment efficiency, running a trained machine learning algorithm, or converting Celsius to Fahrenheit.

  • Enrich data by adding a device's name and location, or setting alerts when it exceeds thresholds.

  • Reshape data to standardize it, such as renaming JSON properties, nesting properties inside other properties, removing properties, and adding properties.

  • Reformat data by converting the output to any data format, such as comma-separated values or descriptive text. For example, you can take JSON, determine if its values exceed thresholds, and replace the JSON with an operator-friendly alert message.

The JavaScript transform method in FairCom Edge allows users to run JavaScript code to modify incoming data each time a record is inserted. This code can access and transform data within the record, excluding specific fields. Examples of these transformations include recalculating data, enriching data, reshaping data, and reformatting data into different formats.

JavaScript transform methoddata transformationtransform datadata processingreal-time data modificationMQTT data transformationSQL data transformationJSON data transformationdata enrichmentdata reshapingdata reformattingdata recalculationchange dataupdate data