【发布时间】:2021-07-19 10:58:29
【问题描述】:
我是第一次玩 Firestore,我使用的是 Python 3.9.5
我已经成功地将数据添加到 python 中的数据库中:
addDoc = db.collection('My-Collection').document()
addDoc.set(val)
其中 val 是一个 json 对象。
但是,当我尝试在 number-field 上查询集合时:
docs = db.collection("Keno-Games").where("game-number", "==", 373).stream()
这是从 Firestore 控制台查询创建器复制的,它确实可以工作,但是当我尝试在我的 python 代码中使用它时它没有。错误是:
Traceback (most recent call last):
File "/Users/timbolton/Desktop/kenoApi/kenoFirestoreIngest.py", line 21, in <module>
docs = db.collection("Keno-Games").where("game-number", "==", 373).stream()
File "/Users/timbolton/Desktop/kenoApi/venv/lib/python3.9/site-packages/google/cloud/firestore_v1/base_collection.py", line 243, in where
return query.where(field_path, op_string, value)
File "/Users/timbolton/Desktop/kenoApi/venv/lib/python3.9/site-packages/google/cloud/firestore_v1/base_query.py", line 278, in where
field_path_module.split_field_path(field_path) # raises
File "/Users/timbolton/Desktop/kenoApi/venv/lib/python3.9/site-packages/google/cloud/firestore_v1/field_path.py", line 84, in split_field_path
for element in _tokenize_field_path(path):
File "/Users/timbolton/Desktop/kenoApi/venv/lib/python3.9/site-packages/google/cloud/firestore_v1/field_path.py", line 64, in _tokenize_field_path
raise ValueError("Path {} not consumed, residue: {}".format(path, path[pos:]))
ValueError: Path game-number not consumed, residue: -number
【问题讨论】:
标签: python google-cloud-firestore