[英]How to create a Firebase Firestore document with user defined document ID?
[英]How to search array and find user ID in Firestore
您確實應該使用array-contains
運算符根據數組值進行過濾。
在您的情況下,您會按照以下方式做一些事情:
cRef = fStore.collection("Users");
cRef.whereArrayContains("colors", "red")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
Log.d(TAG, document.getId() + " => " + document.getData());
}
} else {
Log.d(TAG, "Error getting documents: ", task.getException());
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.