firebasereact-nativegeofirestore

How to explicitly set the ID of newly created GeoFireStore document?


The Add method gives you no way of setting the ID upon document creation and there is not set() method.

Is there any way to set the ID of the new document?


Solution

  • You can generate a new GeoDocumentReference from a GeoCollectionReference by calling doc("id") to specify the ID of the document. With that GeoDocumentReference, you can call its set() method to create that document and write data to it.

    This works exactly like the normal JavaScript API for Firestore.