jsonstore
jsonstore copied to clipboard
Is it possible to push to an array without reading it first?
I have a store where I have a list of songs:
"tracks": ['track1', 'track2']
Is it possible to push track3
to the array?
Or should I GET
the tracks first, push to my local array and then PUT
the result?
Hey @grochadc,
Great question, and as of today, we do not support adding/removing of items from collection via the API, so right now the only way you can achieve that is the method you suggested.
However, we're planning on supporting this feature in the near future.
Implementing HTTP PATCH with JSON Patch should solve this problem.
Thanks for the reply @bluzi
@akshendra Yup, definitely reconsidering it now.
@bluzi a big hurdle, as far as I have found, is that firebase.database
doesn't really have arrays, so there is no support for array methods. They basically store it like objects with numbers are keys. Making it difficult to support even simple methods like pushing, impossible, without fetching the whole array on server, since you don't know the next key.
We can do it in the server, and save half the way. :)
This would be cool!
Hi, there is any update about this feature? Will be awesome.
Regards