Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore supported characters for custom IDs

I would like to create a custom ID for my documents in Firestore, I know all the base 62 (a-z, A-Z, 0-9) characters are supported for custom IDs, I need to know about the special characters (- _ * & $ # @ ! ` ~ % etc) supported by Firestore to use in custom IDs, is there any unsupported special character?

Also want to know about the white space case, can I create a custom ID like abc 123 ?

like image 567
AbuMaaiz Avatar asked May 17 '18 05:05

AbuMaaiz


People also ask

How do you add a custom ID to firestore?

To add Document with Custom ID to Firestore with JavaScript, we call the set method. db. collection("cities"). doc("LA").

Is firestore document ID unique?

Correct, it is extremely unlikely, but not guaranteed.

What data is supported in the firestore?

Note: Cloud Firestore supports a variety of data types for values: boolean, number, string, geo point, binary blob, and timestamp. You can also use arrays or nested objects, called maps, to structure data within a document.

Can you change document ID firestore?

There is no API to change the ID of an existing document, nor is there an API to move a document. If you want to store the same contents in a different document, you will have to: Read the document from its existing key. Write the document under its new key.


1 Answers

This is a late answer, but as I was just looking for this information myself:

The constraints on the document ids (and collection ids are) are:

  • Must be valid UTF-8 characters
  • Must be no longer than 1,500 bytes
  • Cannot contain a forward slash (/)
  • Cannot solely consist of a single period (.) or double periods (..)
  • Cannot match the regular expression __.*__

Document Ids may contain space characters.

The naming constraints on document Ids, collection Ids, and field names are fully documented here:

https://firebase.google.com/docs/firestore/quotas#limits

Google firebase group discussion on this:

https://groups.google.com/forum/#!topic/firebase-talk/bUMpQwGe08k

like image 94
tmcf Avatar answered Oct 08 '22 11:10

tmcf