An array containing fields, where keys are the field
names, and values are field values. Nested arrays are allowed.
Note that unlikeDocumentReference::update(),
field paths are NOT supported by this method.
An array containing fields, where keys are the field
names, and values are field values. Nested arrays are allowed.
Note that unlikeDocumentReference::update(),
field paths are NOT supported by this method.
options
array
Configuration Options
↳ merge
bool
If true, unwritten fields will be preserved. Otherwise, they will be overwritten (removed).Defaults tofalse.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# Cloud Firestore Client - Class DocumentReference (1.53.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.53.0 (latest)](/php/docs/reference/cloud-firestore/latest/DocumentReference)\n- [1.52.0](/php/docs/reference/cloud-firestore/1.52.0/DocumentReference)\n- [1.51.0](/php/docs/reference/cloud-firestore/1.51.0/DocumentReference)\n- [1.50.0](/php/docs/reference/cloud-firestore/1.50.0/DocumentReference)\n- [1.48.1](/php/docs/reference/cloud-firestore/1.48.1/DocumentReference)\n- [1.47.3](/php/docs/reference/cloud-firestore/1.47.3/DocumentReference)\n- [1.46.0](/php/docs/reference/cloud-firestore/1.46.0/DocumentReference)\n- [1.45.2](/php/docs/reference/cloud-firestore/1.45.2/DocumentReference)\n- [1.44.1](/php/docs/reference/cloud-firestore/1.44.1/DocumentReference)\n- [1.43.3](/php/docs/reference/cloud-firestore/1.43.3/DocumentReference)\n- [1.40.0](/php/docs/reference/cloud-firestore/1.40.0/DocumentReference)\n- [1.39.0](/php/docs/reference/cloud-firestore/1.39.0/DocumentReference)\n- [1.38.0](/php/docs/reference/cloud-firestore/1.38.0/DocumentReference)\n- [1.37.7](/php/docs/reference/cloud-firestore/1.37.7/DocumentReference)\n- [1.36.1](/php/docs/reference/cloud-firestore/1.36.1/DocumentReference)\n- [1.35.0](/php/docs/reference/cloud-firestore/1.35.0/DocumentReference)\n- [1.34.0](/php/docs/reference/cloud-firestore/1.34.0/DocumentReference)\n- [1.33.0](/php/docs/reference/cloud-firestore/1.33.0/DocumentReference)\n- [1.32.0](/php/docs/reference/cloud-firestore/1.32.0/DocumentReference)\n- [1.31.0](/php/docs/reference/cloud-firestore/1.31.0/DocumentReference)\n- [1.30.0](/php/docs/reference/cloud-firestore/1.30.0/DocumentReference)\n- [1.28.0](/php/docs/reference/cloud-firestore/1.28.0/DocumentReference)\n- [1.27.3](/php/docs/reference/cloud-firestore/1.27.3/DocumentReference) \nReference documentation and code samples for the Cloud Firestore Client class DocumentReference.\n\nRepresents a reference to a Firestore document.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient();\n $document = $firestore-\u003edocument('users/john');\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Firestore\n\nMethods\n-------\n\n### __construct\n\n### parent\n\nReturns the parent collection.\n\nExample: \n\n $parent = $document-\u003eparent();\n\n### name\n\nGet the document name.\n\nNames are absolute. The result of this call would be of the form\n`projects/\u003cproject-id\u003e/databases/\u003cdatabase-id\u003e/documents/\u003crelative-path\u003e`.\n\nOther methods are available to retrieve different parts of a collection name:\n\n- [DocumentReference::id()](/php/docs/reference/cloud-firestore/latest/DocumentReference#_Google_Cloud_Firestore_DocumentReference__id__) Returns the last element.\n- [DocumentReference::path()](/php/docs/reference/cloud-firestore/latest/DocumentReference#_Google_Cloud_Firestore_DocumentReference__path__) Returns the path, relative to the database.\n\nExample: \n\n $name = $document-\u003ename();\n\n### path\n\nGet the document path.\n\nPaths identify the location of a document, relative to the database name.\n\nTo retrieve the document ID (the last element of the path), use\n[DocumentReference::id()](/php/docs/reference/cloud-firestore/latest/DocumentReference#_Google_Cloud_Firestore_DocumentReference__id__).\n\nExample: \n\n $path = $document-\u003epath();\n\n### id\n\nGet the document identifier (i.e. the last path element).\n\nIDs are the path element which identifies a resource. To retrieve the\npath of a resource, relative to the database name, use\n[DocumentReference::path()](/php/docs/reference/cloud-firestore/latest/DocumentReference#_Google_Cloud_Firestore_DocumentReference__path__).\n\nExample: \n\n $id = $document-\u003eid();\n\n### create\n\nSee also:\n\n- [Commit](https://cloud.google.com/firestore/docs/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Firestore.Commit)\n\n### set\n\nSee also:\n\n- [Commit](https://cloud.google.com/firestore/docs/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Firestore.Commit)\n\n### update\n\nSee also:\n\n- [Commit](https://cloud.google.com/firestore/docs/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Firestore.Commit)\n\n### delete\n\nSee also:\n\n- [Commit](https://cloud.google.com/firestore/docs/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Firestore.Commit)\n\n### snapshot\n\nSee also:\n\n- [BatchGetDocuments](https://cloud.google.com/firestore/docs/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Firestore.BatchGetDocuments)\n\n### collection\n\nGet a reference to a collection which is a child of the current document.\n\nExample: \n\n $child = $document-\u003ecollection('wallet');\n\n### collections\n\nList all collections which are children of the current document.\n\nExample: \n\n $collections = $document-\u003ecollections();"]]