i am doing some work with flutter and firebase, so i can't figure out how add new elements to an existing document who has an existing map with some created fields so.. the map for example is this
'Users':{uid0:{'Name':{'userName0'},uid1:{'Name':{'userName1'}}
An this is my actual code.
Firestore.instance.collection('on_going_matches').where('userSlot',isGreaterThan: 0).snapshots().listen(
(data) => {
Firestore.instance.runTransaction((transaction) async {
await transaction.update(Firestore.instance.collection("on_going_matches").document(data.documents[0].documentID), {
'users': {uid:{'Name':name}},
'userSlot': data.documents[0]['userSlot'] - 1
}
);
})
});
I have another question too, what i can do when "where" condition "where('userSlot',isGreaterThan: 0)" is not found, how i can use this like an if/else statement so, if Firestore query is not found, do a thing.