I am trying to create a tree structure for the tasks from a flat array (since this is the way they come from the DB) by using the transformFlatData property and parentId.
However, when I am trying to map the data to the TaskModel, parentId is always set to null, even when it should have a value.
Is there something I am doing wrong? How can I set the parentId in order to create a tree structure?
Thank you, this seems to work. But my remaining problem is typing. Since we are using typescript in our application, I expect the variable to be a certain type and by doing this, I cannot type it. Is there a way to do this?
And why does it work this way, but not when creating a new TaskModel (or a new Model that extends the TaskModel class in order to add new fields)?
Our typings has definitions for TaskModel & TaskModelConfig, where TaskModelConfig basically contains the fields. You should be able to use it to define the block in that map() as Partial<TaskModelConfig>