我第一次使用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
固定的:
根据Documentation - Constraints on Field Paths,字段路径不能包含
-
字符相关问题 更多 >
编程相关推荐