Connected to the Firestore database using below code,
Query query = dbFirestore.collection("collectionName").whereEqualTo("columnName ==",XXX);
ApiFuture<QuerySnapshot> apiFutureResults = query.get();
From ApiFuture, apiFutureResults.get() ? How to delete the list of documents one by one from here. In my case its only one document for the given condition. I don't see any delete function underneath apiFutureResults .
FYI. This is pure Java Application. No Android. So No listeners please.
CodePudding user response:
To delete the list of documents one by one, you can use the delete() function as in the following example:
// [START firestore_data_delete_doc]
// asynchronously delete a document
ApiFuture<WriteResult> writeResult = db.collection("cities").document("DC").delete();
// ...
System.out.println("Update time : " writeResult.get().getUpdateTime());
// [END firestore_data_delete_doc]
It is important to note that Cloud Firestore does not automatically remove the documents in its subcollections when you delete a document. By reference, you can still access the papers in the subcollection.
A document must be deleted manually along with all of the documents contained in any subcollections.