[英]firestore array_contains condition is ignored (python)
I am using python (3.11) to query google firestore db specifically 'array_contains' condition, but it just ignores it and does not do any filtering我正在使用 python (3.11) 专门查询 google firestore db 的 'array_contains' 条件,但它只是忽略它并且不进行任何过滤
Here is my code:这是我的代码:
tails_ref = db_ref.collection('tails')
tails_ref.where('visible_to', 'array_contains', 'red')
docs = tails_ref.stream()
for doc in docs:
print(f"{doc.id} => {doc.to_dict()}")
as a result I am getting whole collection:结果我得到了整个系列:
0NAjJEgWWZqX9n5PALTp => {..., 'visible_to': ['red', 'blue'], ...}
1KHfzw9zcgISxGKtaWA0 => {..., 'visible_to': ['blue'], ...}
1d3YWvDileK3105UXRTd => {..., 'visible_to': [], ...}
5xaQsc4tD2SSco6g3E8F => {..., 'visible_to': ['red'], ...}
I expect to see only docs with value 'red' in 'visible_to' array What am I doing wrong?我希望在“visible_to”数组中只看到值为“red”的文档我做错了什么?
after posting a question I found a mistake: I need to re-assign reference with condition:发布问题后我发现了一个错误:我需要重新分配条件引用:
tails_ref = tails_ref.where('visible_to', 'array_contains', 'red')
tails_ref = tails_ref.where('visible_to', 'array_contains', 'red')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.