Create a Firestore document reference

Create a Firestore document reference

Documentation pages that include this code sample

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

Code sample

Go

alovelaceRef := client.Collection("users").Doc("alovelace")

Java

// Reference to a document with id "alovelace" in the collection "users"
DocumentReference document = db.collection("users").document("alovelace");

Node.js

const alovelaceDocumentRef = db.collection('users').doc('alovelace');

PHP

$document = $db->collection('samples/php/users')->document('lovelace');

Python

a_lovelace_ref = db.collection(u'users').document(u'alovelace')

Ruby

document_ref = firestore.col("users").doc("alovelace")

What's next

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