Node name limitation?

399 views
Skip to first unread message

Kasbolat Kumakhov

unread,
Aug 25, 2016, 3:54:39 PM8/25/16
to Firebase Google Group
I have a list of products in my Android app which looks like this:

productList
  |-- productName_1
      |-- parameter_1
      |-- parameter_2
      |-- parameter_3
  |-- productName_2
      |-- parameter_1
      |-- parameter_2
      |-- parameter_3
  |-- productName_3
      |-- parameter_1
      |-- parameter_2
      |-- parameter_3

The product names are user generated. I thougth it's a good way to store data, but it appears that there is a name limitation in Firebase (perhaps i missed it in the docs).
When user types "." (dot) i get an exception like this:
com.google.firebase.database.DatabaseException: Invalid Firebase Database path: productList/CoolProduct.. Firebase Database paths must not contain '.', '#', '$', '[', or ']'

Ok. Pretty understandable.
But how to handle this in code and not limit users in product names? Something like escaping sequences or something?
Or perhaps i need to change the scheme and store products under push IDs?

Kato Richardson

unread,
Aug 25, 2016, 4:29:54 PM8/25/16
to Firebase Google Group
Hi Kasbolat,

The restricted characters are covered here. You'll either need to escape those characters (URl encoding almost works, except that you still need to convert periods) or use a more unique/safe identifier.

Using unrestricted names as the keys may also result in duplicates or prevent two entries with the same name. Push ids are, of course, ideal for distributed data, but not always as readable if you're going to be putting them into the URLs. So slugifying the names may be preferable.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/3d1fb713-bcb0-4bf9-a68c-237e111bf540%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Kasbolat Kumakhov

unread,
Aug 26, 2016, 11:13:00 AM8/26/16
to Firebase Google Group
I see. Thanks for the link. As i mentioned - missed it.
Well duplication is not a problem in my case.
Actually I thought of using base64 encoding. What do you think about it?
The point is to encode and decode the strings back. Not just one way.

четверг, 25 августа 2016 г., 23:29:54 UTC+3 пользователь Kato Richardson написал:
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/3d1fb713-bcb0-4bf9-a68c-237e111bf540%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kato Richardson

unread,
Aug 26, 2016, 2:04:20 PM8/26/16
to Firebase Google Group
If they don't need to be human readable in the database, push ids would be simplest and most useful (they're unique to the billions, chronologically ordered, already available in the SDK). If they need to be readable in URLs, et al, then probably slugifying or escaping control chars.

☼, Kato

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Joe White

unread,
Aug 28, 2016, 5:50:29 PM8/28/16
to Firebase Google Group
Use a PushID .. and with a property of name underneath ... may need an alternat node with the names and the associated UIDs to lookup.

Kasbolat Kumakhov

unread,
Aug 29, 2016, 10:48:31 AM8/29/16
to Firebase Google Group
Thanks both of you, but in my case push IDs are not convenient because they add another level of hierarchy which i wanted to avoid.
I'll think about it, though. Thanks again!

четверг, 25 августа 2016 г., 22:54:39 UTC+3 пользователь Kasbolat Kumakhov написал:
Reply all
Reply to author
Forward
0 new messages