In Firestore, document IDs cannot contain spaces or any other special characters. Document IDs are strings that can only contain letters (a-zA-Z), digits (0-9), underscores (_), or hyphens (-). Therefore, you cannot have a space character in a Firestore document ID.

If you have a document ID that contains a space character, you will need to replace it with a valid character, such as an underscore or a hyphen, when creating the document. For example, if you have a document ID "my document", you can replace the space with an underscore to create a valid document ID "my_document" or replace it with a hyphen to create a valid document ID "my-document".

Once you have created the document with a valid document ID, you can access it using the Firestore SDKs or APIs in your programming language of choice, following the standard syntax for accessing Firestore documents. For example, in JavaScript with the Firestore JavaScript SDK, you can access a document with a valid document ID using the following syntax:

javascript
const firestore = firebase.firestore(); const docRef = firestore.collection('myCollection').doc('my_document'); // Replace 'my_document' with the valid document ID

Similarly, you can access the document in other programming languages using the appropriate Firestore SDKs or APIs, following the standard syntax for accessing Firestore documents, and providing the valid document ID that you used when creating the document.

Have questions or queries?
Get in Touch