Delete a Firestore document

Delete a single Firestore document

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample

Go

_, err := client.Collection("cities").Doc("DC").Delete(ctx)
if err != nil {
	// Handle any errors in an appropriate way, such as returning them.
	log.Printf("An error has occurred: %s", err)
}

Java

// asynchronously delete a document
ApiFuture<WriteResult> writeResult = db.collection("cities").document("DC").delete();
// ...
System.out.println("Update time : " + writeResult.get().getUpdateTime());

Node.js

const res = await db.collection('cities').doc('DC').delete();

PHP

$db->collection('samples/php/cities')->document('DC')->delete();

Python

db.collection(u'cities').document(u'DC').delete()

Ruby

city_ref = firestore.doc "#{collection_path}/DC"
city_ref.delete

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser