0
我公司的FireStore结构看起来是这样的:公司的FireStore:从收集查询所有文档
-(coll)users
-(doc)uniqueID
name
email
(coll)clients
-(doc)uniqueID
clientName
clientEmail
我想实现如下:
- 通过FirebaseUI验证流程的用户登录
- 如果用户(从Auth恢复的uid)在firestore db中不存在,我创建一个由他的用户名命名的文档
- 一旦我有了uid,我运行一个查询来加载clie nts收集,以便使用RecyclerView将它们显示在列表中(如果收集为空,则用户尚未创建任何客户端,但我显示空列表屏幕)
我试图使用下面的代码为每documentation:
clientsCollection = db.collection(FIRESTORE_COLLECTION_USERS)
.document(mUid)
.collection(FIRESTORE_COLLECTION_CLIENTS);
clientsCollection
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()){
for (DocumentSnapshot document: task.getResult()){
Log.d(LOG_TAG, document.getId() + " => " + document.getData());
}
} else {
Log.d(LOG_TAG, "error getting documents: ", task.getException());
}
}
});
我得到以下RuntimeException
:
java.lang.NullPointerException: Provided document path must not be null.
我得到这个即使客户端收集退出一些文档它由独特的用户名命名。
感谢您的任何线索,你可以给我! :)