[英]how to query firestore v9 data in react js
How to perform a query with conditional where() clause using firebase and cloud-firestore v9?如何使用 firebase 和 cloud-firestore v9 使用条件 where() 子句执行查询?
useEffect(
() =>
onSnapshot(
collection(db, "Article"),
where("category", "array-contains", "Apple"),
(snapshot) =>
setArticles(
snapshot.docs.map((doc) => ({
...doc.data(),
id: doc.id,
}))
)
),
[]
);
You're missing a query
call:你错过了一个
query
电话:
onSnapshot(
query(
collection(db, "Article"),
where("category", "array-contains", "Apple"),
)
(snapshot) =>
...
Also see the Firebase documentation on queries , which has examples for both the v9 SDK and older/other SDKs.另请参阅有关查询的 Firebase 文档,其中包含 v9 SDK 和旧版/其他 SDK 的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.