I have a polling app where each pole has the following structure-
topic: Topic
questions
{
Q1
{
name: "q1"
type: "Single Choice"
options: ["Yes", "No"]
}
Q2
{
name: "Q2"
type: "MCQ"
options: ["A", "B", "C"]
}
Q3
{
name: "Q3"
type: "LongAnswer"
options: null
}
}
The poll results document looks like this-
{
"Q2": {
"A": 3,
"C": 6,
"B": 3
},
"Q3": {
"Responses": [
"This is my response."
]
},
"Q1": {
"No": 2,
"Yes": 4
}
}
I need to write down a security rule that ensures that a user can make an increment of only 1 in the values and can't change more than one values if the question is of "Single Choice" type. But, the number of questions or options are not known beforehand and the security rules don't allow loops. What should I do?