【发布时间】:2018-10-26 22:36:41
【问题描述】:
我想根据子字符串匹配查询 Cloud Firestore 数据库。关于documentation,可以使用array_contains操作符来完成。
> The where() method takes three parameters: a field to filter on, a
> comparison operation, and a value. The comparison can be <, <=, ==, >,
> >=, or array_contains
但是当我尝试使用它时,我收到以下错误:
doc_ref = db.collection(u'full').where(u'desc', u'array_contains', snippet).get()
obj = doc_ref[0].to_dict()
ValueError: Operator string 'array_contains' is invalid. Valid choices are: <, <=, ==, >, >=.
此时我不知道运算符的格式应该不同,文档已经过时或者我做错了。
【问题讨论】:
-
仅供参考 array_contains 不是“子字符串匹配”。这是数组存在匹配。
标签: python firebase google-cloud-firestore