Adding an object to nested array using Akita state library - Angular 9

Viewed 811

I have the next entity structure inside my Akita Store:

{
    id: 1,
    values: [
        {valueId: 1.1, data: [
            {dataId: 1.3, text: 'abc'},
            {dataId: 1.4, text: 'cba'}
        ]}
    ];
}

I'm trying to add another Object to the data array of a specific value, for example I would like to add {dataId: 1.5, text: 'dfg} to the data of the value with valueId: 1.1. so the result should be like this:

  {
        id: 1,
        values: [
            {valueId: 1.1, data: [
                {dataId: 1.3, text: 'abc'},
                {dataId: 1.4, text: 'cba'},
                {dataId: 1.5, text: 'dfg}
            ]}
        ];
    }

I've tried to do the next thing but it didn't worked:

this.outgoingDataStore.update(1, data => {
    return {
        ...data,
        valuesByComponents: arrayAdd(data.values, {dataId: 1.4, text: 'cba'} )
    };
}); 

Any help would be appreciated

0 Answers
Related