Reputation: 13
How to update the status as true:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference applicationsRef = rootRef.collection("Root");
DocumentReference applicationIdRef = applicationsRef.document("Registration");
applicationIdRef.update("Status",true).addOnCompleteListener(task -> {
}).addOnFailureListener(new OnFailureListener() {
@Override public void onFailure(@NonNull Exception e) {
Log.d("TAG", "onFailure: "+e);
}
});
I was doing by this approach, but I was not getting how to go till status field .
Upvotes: 1
Views: 144
Reputation: 598708
The Map
field is (quite deeply) nested. To update nested fields, you use dot notation like this:
applicationIdRef.update("Map1.Map2.Map3.Status",true)
Also see the Firebase documentation on updating nested fields
But even then, since the value is in an array, there's no way update a single item in an array by its index. So Map1.Map2.Map3.0.Status
won't work. You will need to:
This updating a single item in an array has been covered extensively before, so I recommend checking out some of those answers too.
Upvotes: 1