Firebase Cloud Firestore : Invalid collection reference. Collection references must have an odd number of segments

前端 未结 5 1893
野的像风
野的像风 2020-12-01 18:02

I have the following code and getting an error :

Invalid collection reference. Collection references must have an odd number of segments

<

5条回答
  •  忘掉有多难
    2020-12-01 18:15

    Hierarchical data structures and subcollections are described in the documentation. A collection contains documents and a document may contain a subcollection. The structure is always an alternating pattern of collections and documents. The documentation contains this description of an example:

    Notice the alternating pattern of collections and documents. Your collections and documents must always follow this pattern. You cannot reference a collection in a collection or a document in a document.

    Thus, a valid path to a collection will always have an odd number of segments; a valid path to a document, an even number. Since your code is trying to query a collection, the path length of four is invalid.

提交回复
热议问题