jsonstore icon indicating copy to clipboard operation
jsonstore copied to clipboard

Is it possible to push to an array without reading it first?

Open grochadc opened this issue 6 years ago • 8 comments

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?

grochadc avatar May 30 '18 01:05 grochadc

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.

bluzi avatar May 30 '18 08:05 bluzi

Implementing HTTP PATCH with JSON Patch should solve this problem.

akshendra avatar May 31 '18 08:05 akshendra

Thanks for the reply @bluzi

grochadc avatar Jun 04 '18 19:06 grochadc

@akshendra Yup, definitely reconsidering it now.

bluzi avatar Jun 09 '18 10:06 bluzi

@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.

akshendra avatar Jun 09 '18 14:06 akshendra

We can do it in the server, and save half the way. :)

bluzi avatar Jun 09 '18 15:06 bluzi

This would be cool!

eklem avatar Aug 17 '18 08:08 eklem

Hi, there is any update about this feature? Will be awesome.

Regards

Frankusky avatar Sep 15 '19 14:09 Frankusky