mar*_*987 9 android firebase google-cloud-firestore
我得到了一个相当简单的错误:
Document references must have an even number of segments.
Run Code Online (Sandbox Code Playgroud)
我知道它告诉我什么以及如何修复它,但是它在集合引用中给了我这个错误。
CollectionReference collectionReference = getFirebaseInstance()
.collection(Constants.USERS)
.document(userId)
.collection(Constants.CONTACTS);
Run Code Online (Sandbox Code Playgroud)
在我的数据库中,路径是 (COLLECTION) < DOCUMENTS > (COLLECTION) < DOCUMENTS > 我试图在 users/{id}/contacts 处获取用户的所有联系人,但它只是抛出这个错误,有什么想法吗?
getFirebaseInstance 是我创建的一种方法,用于始终获取当前
FirebaseFirestore.getInstance();
Run Code Online (Sandbox Code Playgroud)
Dou*_*son 18
您的userId变量中可能有斜线。文档 id 不能有斜线,因为它们在形成文档的“路径”时被解释为集合和文档之间的分隔符。
字符串也有可能为空,这是无效的。
| 归档时间: |
|
| 查看次数: |
12561 次 |
| 最近记录: |