skip to Main Content

In order to save user credentials I use Firestore. In my app, I put an image picker only in the profile screen not in the authentication screen. I want the user to pick an image and upload it to Firebase storage after authenticating. Then the URL of the image taken from Firebase storage should be in Firestore. It is Firestore image after authentication

How can I add a single ‘photoUrl’ key field and value after authentication? I want a patch request. It only adds the desired field.

I want to get this one

I saw the update method, but it update the whole JSON data.

2

Answers


  1. I saw the update method, but it update the whole JSON data.

    It sounds to me that you have used the set() function which:

    Sets data on the document, overwriting any existing data.

    However, if you have passed a SetOptions object as an argument, then:

    If SetOptions are provided, the data can be merged into an existing document instead of overwriting.

    If you need to simply update a document, you have to create an object of type Map<Object, Object?> and pass it to the update function.

    Login or Signup to reply.
  2. For this you need to know the document ID of the user and update the value with the update method of FirebaseFirestore.

    FirebaseFirestore.instance.collection("collectionName").doc("documentId").update({"photoUrl": "actualUrl"});
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search