使用“在数组中”过滤条件查询 Firestore 集合

使用“在数组中”过滤条件查询 Firestore 集合

包含此代码示例的文档页面

如需查看上下文中使用的代码示例,请参阅以下文档:

代码示例

Go

cities := client.Collection("cities")
query := cities.Where("regions", "in", [][]string{{"west_coast"}, {"east_coast"}}).Documents(ctx)

Java

CollectionReference citiesRef = db.collection("cities");

Query query =
    citiesRef.whereIn(
        "regions", Arrays.asList(Arrays.asList("west_coast"), Arrays.asList("east_coast")));

Node.js

const exactlyOneCoast = await citiesRef.where('region', 'in',
    [['west_coast', 'east_coast']]).get();

PHP

$rangeQuery = $citiesRef->where('regions', 'in', [['west_coast'], ['east_coast']]);

Python

cities_ref = db.collection(u'cities')

query = cities_ref.where(
    u'regions', u'in', [[u'west_coast'], [u'east_coast']]
)
return query

Ruby

cities_ref = firestore.col collection_path
exactly_one_cost = cities_ref.where "regions", "in", [["west_coast"], ["east_coast"]]

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器