【发布时间】:2020-03-26 12:38:55
【问题描述】:
如何获得一个集合,其中查询应该适用于文档内的数组。
文档示例:我想知道如何查询品牌为fiat和seat的文档
{
"name":"test 1",
"brands":[
{
"brand":{
"id":1,
"name":"Fiat",
"slug":"fiat",
"image":null,
"year_end":null,
"year_start":null
},
"released_at":"2018-10-26"
},
{
"brand":{
"id":2,
"name":"Seat",
"slug":"seat",
"image":null,
"year_end":null,
"year_start":null
},
"released_at":"2018-10-26"
},
{
"brand":{
"id":3,
"name":"Mercedes",
"slug":"mercedes",
"image":null,
"year_end":null,
"year_start":null
},
"released_at":"2018-10-26"
},
{
"brand":{
"id":4,
"name":"Yamaha",
"slug":"yamaha",
"image":null,
"year_end":null,
"year_start":null
},
"released_at":"2018-10-26"
}
]
}
我尝试过类似的方法:
.collection("motors")
.where("brands.slug", "array-contains-any", ["fiat", "seat"])
但这不起作用我无法通过documentation 弄清楚如何获得它。
【问题讨论】:
标签: firebase google-cloud-firestore