I’m working on a project where I need to set-up a listener on a document, so I can poll the results of specific map fields on it as they change. These are tracking data aggregations from questions - example structure attached. This is working fine, as per the code below.
[FirestoreData]
public class Question1
{
[FirestoreProperty("I do")]
public string beer { get; set; }
[FirestoreProperty("I don't")]
public string wine { get; set; }
}
public void getDataFeed()
{
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
DocumentReference aggs = db.Collection("aggregations").Document("s1e1");
ListenerRegistration aggregation = aggs.Listen(snapshot =>
{
Question1 question1 = snapshot.GetValue<Question1>("questions.q3");
Debug.Log(question1.beer);
Debug.Log(question1.wine);
});
}
However, I won’t know in advance exactly what the fields to be queried will be, as it’s running as part of a live event.
Is it possible to dynamically create a FirestoreData class at runtime to match a dynamically created query path?
Is there simply a better approach for the problem I'm trying to solve?
Many thanks in advance.