Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
空文档的Android Firestore id_Android_Firebase_Google Cloud Firestore - Fatal编程技术网

空文档的Android Firestore id

空文档的Android Firestore id,android,firebase,google-cloud-firestore,Android,Firebase,Google Cloud Firestore,如何获取空文档的id(没有字段但包含集合的文档) 比如说 public void getUsersLists(OnSuccessListener<List<String>> callback) { storeCollection().get(getSource()).addOnCompleteListener(task -> { if (task.isSuccessful()) { QuerySnapshot r

如何获取空文档的id(没有字段但包含集合的文档)

比如说

public void getUsersLists(OnSuccessListener<List<String>> callback) {

    storeCollection().get(getSource()).addOnCompleteListener(task -> {

        if (task.isSuccessful()) {

            QuerySnapshot result = task.getResult();
            List<String> stringList = parseResult(result);
            callback.onSuccess(stringList);

        } else {
            callback.onError(task.getException());
        }

    }).addOnFailureListener(callback::onError);
}

private List<String> parseResult(QuerySnapshot result) {

    List<String> list = new ArrayList<>();

    if (result != null) {

        for (DocumentSnapshot snapshot : result.getDocuments()) { <<----documetns is zero
            String name = snapshot.getId();

            list.add(name);
        }

    }

    return list;
}

private CollectionReference storeCollection() {
    return firestore()
            .collection(COLLECTION_DATA)
            .document(AuthManager.getUserId())
            .collection(COLLECTION_STORES);
}
public void getUsersList(OnSuccessListener回调){
storeCollection().get(getSource()).addOnCompleteListener(任务->{
if(task.issusccessful()){
QuerySnapshot result=task.getResult();
List stringList=parseResult(结果);
callback.onSuccess(stringList);
}否则{
callback.onError(task.getException());
}
}).addOnFailureListener(回调::onError);
}
私有列表解析结果(QuerySnapshot结果){
列表=新的ArrayList();
如果(结果!=null){

对于(DocumentSnapshot snapshot:result.getDocuments()){您无法查询不存在的文档。用于根据实际存在的文档和字段进行查询的Firestore索引-索引无法处理不存在的文档


如果有在不存在的文档ID下组织的子集合,您需要知道这些子集合的路径,以便使用它们,包括文档ID。如果您不知道它们组织的文档ID,则无法通过编程方式发现它们。

如果您的集合包含多个文档,则您需要筛选该文档。集合返回0个文档,因为该文档不包含字段(但文档存在,我在控制台中看到它们),那么我可以过滤什么呢?你能发布完整的代码吗?你尝试了什么?Ashish补充了更多code@PavelPoley尝试使用
QueryDocumentSnapshot
而不是
QuerySnapshot
,您将很容易地检查其
存在性
大小
元数据
。这是用于此目的的文档