我使用python尝试向firestore集合中的750多个文档添加字段,但是当尝试这样做时,只有我的前55个文档得到更新。我假设这是因为firestore的写限制,但不知道原因。在
注意:actividades
是一个大小约为20个元素的数组,每个元素只有3个属性。在
import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate('avancesAccountKey.json')
default_app = firebase_admin.initialize_app(cred)
db = firestore.client()
count = 0
avances = db.collection('avances').get()
for e in avances:
db.collection('avances').document(e.id).update({
'vigente': False
})
count += 1
print(count) # count is 55 when trying to update, 757 otherwise
到底发生了什么?我该怎么解决?在
不应在遍历集合时对其进行变异。取而代之的是获取文档引用,然后迭代。在
参考号:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/6033
更新:Firestore python客户端似乎有一个20 second timeout for the generator returned from a query。在
相关问题 更多 >
编程相关推荐