skip to Main Content

I want to change the value of "check" for particular values of "attendance"

FirebaseFirestore.instance.collection('students').doc().set({
            'doc':FirebaseFirestore.instance.collection('students').doc(),
            'attendance':title,
            'check':true
          });

Here's the firebase database

What code should I use if I want to change the value of the field of that particular documents.

2

Answers


  1. Use replace set to update Like this:

    FirebaseFirestore.instance.collection('students').doc().update({
         
                'check':true
              });
    
    Login or Signup to reply.
  2. When you call doc() without parameters it generates a reference to a new document.

    If you want to update an existing document, you’ll need to pass the ID of tht document to the doc(...) call.

    FirebaseFirestore.instance.collection('students').doc('rYvghLkro3pYcclwpCPI').update({
      'attendance': 'new title',
    });
    

    If you don’t know the ID of the document you want to update, you can use a query to look that up based on some value(s) in the document that you do know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search