Generating synthetic variables from existing fields in the collection

I’m seeking advice on the implementation of real-time calculation of synthetic variables from two existing variables stored in MongoDB, with Nodejs & React frontend integration. Below is a detailed overview of my current architecture and specific challenges:

Collections Schema:-
Devices Collection: Stores information about different datasources.

  "_id": ObjectId("..."),
  "name": "Datasource Name",
  "description": "Description of the datasource"

Variables Collection: Stores information about variables, including their names, descriptions, and units of measurement.

  "_id": ObjectId("..."),
  "name": "Variable Name",

Values (Time Series) Collection: Stores time-stamped values for variables associated with variables belonging to a datasource.

  "_id": ObjectId("..."),
  "ts": ISODate("..."),          
  "val": 123.45,                   
  "metafield": {
    "variableId": ObjectId("..."),

Consider a scenario where data from a device is captured (every 10 seconds) and stored with multiple variables. For instance:

  "power-1": 98.2,
  "power-2": 23.5,
  "voltage-1": 56.77,
  "voltage-2": 122.56,
  "frequency-1": 8,
  "frequency-2": 54.7

Users should be able to select two variables (e.g., power-1** and power-2) and define an arithmetic operation (e.g., ((power-1 + power-2) * 100) / 1000). The result, referred to as a synthetic variable (e.g., power), should be calculated in real-time and displayed in real-time to the user whenever the user logs in.
How can i achieve this using mongodb with the above mentioned schema?

With an aggregation you can computed what ever result you desire.

A view is defined by an aggregation.

I would say that for what ever synthetic data you want you can define a view using an aggregation pipeline that does what ever you please.

That is probably too generic of an answer, but it is probably the you will get because when you write

it looks like you are inquiring about user interface and this is outside the realm of the data storage. Data wise it can be done, how you would do it in a GUI is probably very complicated.