Is there an easy way to populate a datasource from "Run code"?

I have data that is stored as a comma separated string that I want to store in a temporary datasource for use in a cip component. Is there an example for how to populate an datasoruce from e.g the Run Code component?
Or are there better ways to achieve the same result?

I have been able to do it with runtime datasources. Because any datasource is an array of objects you can just use the push() method to add objects to it. I haven’t tried with database connected datasources, but I wouldn’t do it.

2 Likes

Hello Lars,
As Marc wrote, you can do that in a run code node. You can even change the existing data array (run time or not) using this code node and all array capabilities in javascript, sometimes quite useful for us to reorder the dataset or manipulate it.
One of the differences we saw is that no _id are generated by default, but ids are generated when persisted

2 Likes

Hi @Marc_Quel & @jeremy.jean. Thanks. It worked like a charm :slight_smile:

1 Like