Reputation: 2407
Hi I'm simply trying to add a map under the messages parent which contains a 'messageText' field and 'messageSender' field, how do you add values to a map in Firebase?
This is the code, I know it doesn't work but hopefully helps you understand what I'm trying to achieve:
_firestore.collection('chats').document(chatID.documentID).updateData({
['messages']['messageText']: 'this is message text.',
['messages']['messageSender']: 'this is the sender.',
});
Thanks.
Upvotes: 0
Views: 1047
Reputation: 317467
I think you want something more like this:
_firestore.collection('chats').document(chatID.documentID).updateData({
'messages': {
'messageText': 'this is message text.',
'messageSender': 'this is the sender.'
}
});
Upvotes: 1