为什么.whereEqualTo不起作用?

时间:2018-04-22 10:19:40

标签: android firebase google-cloud-firestore

为什么这样工作

Query firstQuery1 = firebaseFirestore.collection("Test").whereEqualTo("test", "1");

这不起作用

Query firstQuery1 = firebaseFirestore.collection("Test");
firstQuery1.whereEqualTo("test", "1");

1 个答案:

答案 0 :(得分:2)

firestore.collection("Test")返回CollectionReference类型的对象,而ref.whereEqualTo(..)返回Query

所以而不是

Query firstQuery1 = firestore.collection("Test");
firstQuery1.whereEqualTo("test", "1");

它需要

CollectionReference ref = firestore.collection("Test");
Query query = ref.whereEqualTo("test","1");