{
"userID": "MyID123"
"voteInfo": {
"docId1": 1
"docId2": 1
"docId3": 2
....
}
}
I would like to record which number the user voted for each two-point questionnaire. At first, only the user ID exists in the ‘users’ document, and I want to add data whenever I update it.
My code that is not working is as follows.
let userID = "MyID123"
let docID = "Ffeji341Fje3"
db.collection("users").document(userID).updateData([
"voteInfo": [
docID: 1
]
])
2
Answers
If you want to store the vote count for a number of keys:
You can do this pretty easily through dot notation.
Given this Firestore structure
here’s a function to append
docId4: 1
to the existing docs