Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Delete a field from Firebase Firestore where the field/key has a period/punctuation (".") - modular v9 JavaScript SDK

$
0
0

This question is for a React Native Expo mobile App if that matters.

I have a flat database object. Using the documentation as an example:

I have added a field/key called "example.com" with some arbitrary value.The object then looks like this:

{capital: "words",location: "other words","example.com": "more words"}

I want to delete the key "example.com" key from the database, and I am using pretty much the same code as in the example from the documentation.

const cityRef = doc(db, "cities", "BJ");const payload = {"example.com": deleteField(),};await updateDoc(cityRef, payload);

This does not delete the "example.com" key. I understand that this attempts to delete the "com" key from the "example" object within the main database document, which is not what I want, but I do not understand how to rework this code to treat the entire string as a key.

I have looked at some similar questions here on SO(links at the bottom) that came to the conclusion that they had to use FieldPath, but the syntax is outdated, and no longer works on the current version of Firestore(or at least I can not find the documentation for FieldPath for the version I am using, linked above).

And tips on how to get this working (deleting a field with a period) would be appreciated.

Link to similar problems:


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>