Spam Me
Spam Me

Reputation: 33

What is the difference between Document ID and Document name in Firestore?

In this link, it is specified in one of the bullet points of

Constraints on document IDs

that it must be no longer than 1500 bytes and just below that we have

Maximum size for a document name

must be no longer than 6 KiB.

I did not find any distinction between document ID and document name in the documentation, I think document ID and document name are the same, but then the above quotes are conflicting.

Upvotes: 3

Views: 903

Answers (1)

Mohammad Kurjieh
Mohammad Kurjieh

Reputation: 1143

Yes indeed it is confusing and buried in the documentation. But I was able to find it in the size calculations website. Link

In a nutshell the document name is basically the size of the path + document id + 16 extra bytes. Whereas document id is the one that identifies every document in a collection. Therefore you can't set document name manually, it is automatically generated.

It shouldn't be a problem in the most cases, unless you have a very nested collection structure and long document ids. But keep in mind this is not affected with long or deeply nested fields, it only apply to document ids. But in that case you will be affected with the maximum document size.

Example from the link above to calculate it:

For a document in the subcollection users/jeff/tasks with a string document ID of my_task_id, the document name size is 6 + 5 + 6 + 11 + 16 = 44 bytes:

6 bytes for the users collection ID

5 bytes for the jeff document ID

6 bytes for the tasks collection ID

11 bytes for the my_task_id document ID

16 additional bytes

Upvotes: 1

Related Questions