datayoga-io/datayoga

Introduce `foreach` in `relational.write` for exploding nested data

Closed this issue · 0 comments

Currently, the relational.write function writes a single record to the database, even if the input data contains nested values. This makes it difficult to store and query nested data in a relational database.

To address this, I suggest introducing a foreach loop in the relational.write function, so that it can write multiple records to the database for each nested value. This would allow for more efficient storage and querying of nested data in a relational database.

Implementation details:

  1. Add a foreach loop to the relational.write function that iterates over the nested values and creates a record for each item.
  2. The mapping part should contain the nested fields so those will be written as separate records to the desired DB table.
  3. Update the function documentation to reflect the new behavior.

Expected Outcome:
By introducing foreach in relational.write, users will be able to store and query nested data more efficiently in a relational database. This feature will enhance the functionality and usability of the relational.write function.