Failed assertion while trying to get single document from firebase

Viewed 91

I am trying to get simply a document from my firebase collection
but i get this error: Unhandled Exception: PlatformException(Error 5, FIRFirestoreErrorDomain, No document to update
I have a document with the document id i checked it by printing
and this is my code:

  void updateBalanceOfSender() async {
    var docID;
    Firestore.instance
        .collection('balance')
        .where('user', isEqualTo: loggedInUser.email)
        .snapshots()
        .listen((data) =>
            data.documents.forEach((doc) => print(docID = doc.documentID)));
    _firestore
        .collection('balance')
        .document(docID)
        .updateData({'balance': '1'});
  }
1 Answers

You are passing the wrong arguments to where method. Use the code below:

 void updateBalanceOfSender() async {   

    var document = await Firestore.instance      
    .collection('balance')      
    .where(“user”,isEqualTo: loggedInUser.email);

    print(document);

}

Have a look at this to see how to perform queries.

This question might also help.

Related