3

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

timdeschryver
  • 14,415
  • 1
  • 19
  • 32
Anna
  • 131
  • 2
  • 11
  • It looks like you are going to have arrayAdd or arrayUpdate at a deeper level, The objects with properties `dataId` and `text` are in array property `data` nested in each object of `data.values`, such as `data.values[0].data`. – Alexander Staroselsky Oct 16 '20 at 21:45
  • Im having the same challenge , have an Entity store with nested arrays, and trying to update the deepest level :) , in your case, an object in the data array .. @ Alexander Staroselskycould you provide an example with the solution you mentioned? – keygjones Jan 22 '21 at 09:36

0 Answers0