0

I have noticed on all other posts that any node/key with children was saved in the database in quotes and mine are not.

mine

Locations{
    indexOn: "g"
}

others/what I assume it should be

Locations{
        ".indexOn": "g"
    }

I didn't think anything of it till I came up on a similar error as this with the ".indexOn". I tried adding ".indexOn" but i received the error that no key can have the symbol .(along with a few other characters that aren't allowed) so I put it in without the . like so:

Locations{ (specific id){ g: "345jh3i5jh" l{ 0: 37 1: -120 } indexOn: "g" user: "0987435098723098Gjhf90" } }

So It seems to work as the observeEventType is returning the correct result sometimes but it still also gives me the error that i need to put ".indexOn" in database. How do I do this?


Any help and explicit examples would be appreciated as there are probably more problems with everything than I addressed. Doing this in swift and thanks for the read!

Community
  • 1
  • 1
KellysOnTop23
  • 1,325
  • 2
  • 15
  • 34
  • 1
    Please limit to a single question per post and provide the minimal code that reproduces the problem that the question is about. For your first question I now have trouble understanding what the problem is. – Frank van Puffelen Aug 06 '16 at 22:10
  • I have fixed my question to just the second problem as I was able to solve the first one. Thanks for checking it out @FrankvanPuffelen, I see you're becoming the guru on firebase here at stack – KellysOnTop23 Aug 06 '16 at 23:11
  • Totally solved my issue!! thanks!!! – KellysOnTop23 Aug 06 '16 at 23:41

1 Answers1

0

You seem to be trying to add index definitions to your database. That is indeed a great way to ensure the server can order and filter the data before returning the results to your app.

Indexes are defined by adding them to your Firebase Database rules in the Firebase Console > Database > Rules. Don't try to add them to your actual database, since:

  • you won't be able to save them, since they have a . in their key, which is an illegal character in the database
  • adding them won't help, since the database server only searches for .indexOn definitions in the database rules

See the Firebase documentation on adding indexes for more.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807