[英]How to use array-contains in firestore web interface
I'm trying to filter a firestore collection based on an object in an array.我正在尝试根据数组中的 object 过滤 firestore 集合。 I have an array of categories and I want to filter by a specific category.
我有一系列类别,我想按特定类别进行过滤。 I read in this answer that you have to use the full object as the query value.
我在这个答案中读到你必须使用完整的 object 作为查询值。
In this example, the object is {'level': 1, 'name': "Furniture"}
在这个例子中,object 是
{'level': 1, 'name': "Furniture"}
If I use this value through the API using node it returns relevant documents.如果我使用节点通过 API 使用此值,它会返回相关文档。
However when I'm running the query in firestore's web interface, it's not returning any matches.但是,当我在 firestore 的 web 界面中运行查询时,它没有返回任何匹配项。 I'm guessing it's because it's wrapping the object in quotes because the data type is a string...
我猜这是因为它用引号引起来了 object 因为数据类型是字符串...
query from node:来自节点的查询:
.collection("products").where("categories", "array-contains", {'level': 1, 'name': 'Furniture'})
query preview when using firestore web interface:使用firestore web接口时查询预览:
.collection("products").where("categories", "array-contains", "{'level': 1, 'name': 'Furniture'}")
Is this a limitation of using the web interface or am I doing something wrong here?这是使用 web 接口的限制还是我在这里做错了什么? The only data types I can use in array-contains are string, number and boolean.
我可以在 array-contains 中使用的唯一数据类型是字符串、数字和 boolean。
This is a limitation of the web interface.这是 web 接口的限制。 It doesn't give you the ability to specify an object parameter to the query.
它不会让您能够为查询指定 object 参数。 You could file a feature request with Firebase support to ask for this if it's important to you.
如果这对您很重要,您可以通过 Firebase 支持提出功能请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.