我在firestore中有一个名为XYZ的收藏。其中有500个不同字段的文档。 我必须使用where子句从集合中删除多个文档
cred = credentials.Certificate('XXXX')
app = firebase_admin.initialize_app(cred)
db = firestore.Client()
batch = db.batch()
doc_ref = db.collection('collection_name').where(u'month', '==', 07).get()
for doc in doc_ref:
batch.delete(doc)
batch.commit()
我试过了,但最后还是出错了
AttributeError: AttributeError: 'DocumentSnapshot' object has no attribute '_document_path'
寻求帮助
您正在将DocumentSnapshot对象传递给
batch.delete()
,这是不允许的。您必须传递DocumentReference对象,该对象可以在DocumentSnapshot的属性中找到相关问题 更多 >
编程相关推荐