I have a large array that can be reordered and stored in a NoSQL database (Firebase Realtime Database). I use Ionic4 ion-reorder-group to sort them.
I am currently saving the data as follows:
{
Data:
0:{
N1:'',
N2:'',
N3:false
},
1:{
N1:'',
N2:'',
N3:false
},
...
}
But by add an object at the beginning, I have to update the full-array in the server. Problem is if I have 1'000 objects and add 10 new ones at the beginning, I have written 10'000 objects in the server.
So what is the best way to structure a large reorder array list? My idea was to work with pushId, but I have not found a solution where the problem no longer exists. In the code below you can see my idea, but the problem is the same that everything has to be updated and a lot of pushId need more memory...
{
Data:
[pushId]:{
P: 0, // Position at the array
N1:'',
N2:'',
N3:false
},
...
}