I've a collection named XYZ in my firestore. And there are 500 documents with different fields in it. I have to delete multiple documents using a where clause from the collection.
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()
I tried this but ending up with an error
AttributeError: AttributeError: 'DocumentSnapshot' object has no attribute '_document_path'
Looking for help!
get()and get document references from the results in order to pass them tobatch.delete(). You can't pass a Query object. - Doug Stevenson