Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

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

Open
grochadc opened this issue May 30, 2018 · 8 comments
Open

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

grochadc opened this issue May 30, 2018 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@grochadc
Copy link

grochadc commented May 30, 2018

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?

@bluzi
Copy link
Owner

bluzi commented May 30, 2018

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 bluzi added the help wanted Extra attention is needed label May 30, 2018
@akshendra
Copy link
Contributor

Implementing HTTP PATCH with JSON Patch should solve this problem.

@grochadc
Copy link
Author

grochadc commented Jun 4, 2018

Thanks for the reply @bluzi

@bluzi
Copy link
Owner

bluzi commented Jun 9, 2018

@akshendra Yup, definitely reconsidering it now.

@akshendra
Copy link
Contributor

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

@bluzi
Copy link
Owner

bluzi commented Jun 9, 2018

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

@eklem
Copy link

eklem commented Aug 17, 2018

This would be cool!

@Frankusky
Copy link

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

Regards

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants