【发布时间】:2020-01-10 14:35:21
【问题描述】:
我正在使用 python 在 firebase firestore 上执行此查询:
groups = ['AG', 'PA']
docs = db.collection(u'companies').document(company).collection('counts').\
document(count_name).collection('preprocess').\
where('status', '==', 'done').where('statuslayers', '==', 'done').\
where('statuslive', '==', 'created').\
where('load', '==', False).where('group', 'in', groups).\
order_by(u'area').stream()
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
触发了这个错误:
运算符字符串“in”无效。有效的选择是:、>=、array_contains。
firebase documentation 页面上的示例非常接近:
cities_ref = db.collection(u'cities')
query = cities_ref.where(u'country', u'in', [u'USA', u'Japan'])
return query
我找不到导致此错误的任何原因,如果我删除 where('group', 'in', groups) 子句,一切正常。
我的谷歌相关包:
- google-api-core 1.15.0
- google-api-python-client 1.7.11
- google-auth 1.10.0
- google-auth-httplib2 0.0.3
- 谷歌云 0.34.0
- google-cloud-core 1.1.0
- google-cloud-firestore 1.6.1
- 谷歌云存储 1.24.1
- google-resumable-media 0.5.0
- googleapis-common-protos 1.6.0
【问题讨论】:
-
似乎添加了对此的支持fairly recently,但如果您确定有
google-cloud-firestore==1.6.1ISTM,它应该有该更新,但您可能需要仔细检查它是否确实存在并且您'正在使用你认为你正在使用的包的版本。 -
@Iguananaut 我快速查看了更新日志,似乎
IN是在 1.6.0 中添加的。我不确定为什么它对 Randolfo 不起作用。
标签: python firebase google-cloud-firestore