[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested array union and remove support #1466

Closed
MaticConradi opened this issue Apr 7, 2021 · 3 comments
Closed

Nested array union and remove support #1466

MaticConradi opened this issue Apr 7, 2021 · 3 comments
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API.

Comments

@MaticConradi
Copy link

Support for updating or removing elements inside nested arrays would be fantastic. Having to fully overwrite the document to update a single field isn't great as I fear there may be a situation where a race condition does something unexpected.

@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Apr 7, 2021
@dconeybe dconeybe self-assigned this Apr 7, 2021
@dconeybe
Copy link
Contributor
dconeybe commented Apr 7, 2021

Hi @MaticConradi. Thank you for the request. Firestore in general has limited support for removing elements from nested arrays. If I understand your request correctly, the limitations you are experiencing are an unfortunate part of Firestore as a whole and cannot be implemented with changes to this repository alone.

Here is an example of a nested array that can be removed from. A document contains a dictionary that has a key/value pair whose value is an array. In this case, FieldValue.arrayRemove() can be used, something like this:

db.collection('users').doc('Frank').update({
  'favorites.colors': FieldValue.arrayRemove('blue')
});

Here is an example of a nested array that cannot be removed from. A document contains an array of dictionaries with key/value pairs whose values are arrays. In this case there is no way to index into the top-level array with FieldValue.arrayRemove() and therefore cannot remove from one of those "nested" arrays.

I realize, however, that I may not be answering your question. If that is the case, could you provide a code example that creates a document with a "nested" array that you are requesting removal support for?

@MaticConradi
Copy link
Author

The second example is what I've been looking for. It's unfortunate that this is Firestore's underlying issue. For now I have decided to work around the issue, however I'm sure there are others looking for the same feature. Clearly it's possible to manually go into a Firestore database on Firebase for example and remove/edit/add a filed in an array of key/value pairs.

I'll close this for now since it's not relevant to the NodeJS library.

@dconeybe
Copy link
Contributor
dconeybe commented Apr 8, 2021

It would be great if you could "officially" request this feature so it can be prioritized along with others. Since it involves the Firestore backend and all client SDKs, it needs to be requested via support:

  1. Go to https://firebase.google.com/support
  2. Click "Bugs and Features"
  3. Click "Feature Request"
  4. For "Platform" select "Other, Multiple, or N/A"
  5. For "Firebase Product" select "Cloud Firestore"
  6. Make sure to link to this GitHub issue in the description of the issue.

Thanks again for raising this feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API.
Projects
None yet
Development

No branches or pull requests

2 participants