2
votes

I am new to firebase and is stuck in database query. I am using Firebase in my Unity game. Here is my sample database structure:

DB Structure

My rules are:

{
  "rules": {
    ".read": "auth != null",
    ".write":"auth != null",
    "matches": {
        ".indexOn": "matchTypeStr"
    }
  }
}

and I am querying like this:

Query searchQuery = FirebaseDatabase.DefaultInstance.RootReference.Child("matches").OrderByChild("matchTypeStr").EqualTo("kMatchEmail")
                    .LimitToFirst(10);

searchQuery.GetValueAsync().ContinueWith(delegate(Task<DataSnapshot> task) {

});

The problem is that query never executes, it does not come inside the completion block. If I remove the rules, it works fine but it turns off indexing and I get the following warning:

PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "matchTypeStr"' at matches to your security and Firebase Database rules for better performance

I am unable to find my fault. Any help would be greatly appreciated.

1
Have you tried to do it without the .EqualTo("kMatchEmail"? Maybe you simply aren't getting any matches. - André Kool
Yes, its working without it. But it should work even if there is no match, it should not just hang. It should come inside completion block and snapshot should return null or something like that. Currently, it just keeps on running forever. - kashif789us

1 Answers

0
votes

It was an issue in firebase SDK. I contacted them and it produced on their side. They fixed in SDK version 3.0.2. Unity SDK