添加条件后,Firestore查询无法获取文档

时间:2019-08-28 02:09:47

标签: java android google-cloud-firestore

我正尝试通过查询从Firestore获取文档,以仅获取具有特定字段值的文档。当我添加过滤器后,从我看过的所有内容看都可以使用的过滤器,它什么也不返回。

这是代码:

ArrayList<Service> services = new ArrayList<>();

db.collection("users/" + user.getUid() + "/" + Constants.SERVICES_TABLE)
         //customerID is a String field in this method block
        .whereEqualTo("customerID", customerID)
        .get()
        .addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                for (QueryDocumentSnapshot document : task.getResult()) {

                    //this code is not reached because QueryDocumentSnapshot always has a length of 0

                    Service service = new Service(
                            document.get("date").toString(),
                            document.get("service").toString(),
                            document.get("notes").toString(),
                            document.get("customerID").toString(),
                            document.get("cost").toString(),
                            document.get("tips").toString());

                    services.add(service);

                }

                myCallback.onCallback(services);

            } else {
                Log.d("tag", "Error getting documents: ", task.getException());
            }
        });

当我删除查询过滤器时,我按预期方式获得了所有Service对象,但是使用该过滤器却什么也没收到。

enter image description here

0 个答案:

没有答案