skip to Main Content

Is possible to have repeated document IDs in the same collection group but in different parents?

Ex.

Collecctions:

  • Collection user
  • Collection group whishlist under collection called

Documents:

  • Doc1 => user/USER_ID_1/whishlist/DEFAULT_LIST
  • Doc2 => user/USER_ID_2/whishlist/DEFAULT_LIST

2

Answers


  1. Yes, it’s possible. You should be able to try this easily for yourself by creating such documents in the console.

    Login or Signup to reply.
  2. According to the official documentation regarding the document IDs:

    The names of documents within a collection are unique. You can provide your own keys, such as user IDs, or you can let Cloud Firestore create random IDs for you automatically.

    So the IDs of the documents in Firestore should be unique within the same collection but since you’re asking about a collection group (different collections or sub-collections), then yes, you can have documents with the same IDs.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search