Skip to content

Commit 0453b02

Browse files
authored
feat: add firestore reference data type (GoogleCloudPlatform#1036)
1 parent 6e6fd0a commit 0453b02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

firestore/src/add_doc_data_types.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function add_doc_data_types($projectId)
3939
$db = new FirestoreClient([
4040
'projectId' => $projectId,
4141
]);
42+
// Set the reference document
43+
$db->collection('data')->document('two')->set(['foo' => 'bar']);
4244
# [START fs_add_doc_data_types]
4345
$data = [
4446
'stringExample' => 'Hello World',
@@ -47,7 +49,8 @@ function add_doc_data_types($projectId)
4749
'dateExample' => new Timestamp(new DateTime()),
4850
'arrayExample' => array(5, true, 'hello'),
4951
'nullExample' => null,
50-
'objectExample' => ['a' => 5, 'b' => true]
52+
'objectExample' => ['a' => 5, 'b' => true],
53+
'documentReferenceExample' => $db->collection('data')->document('two'),
5154
];
5255
$db->collection('data')->document('one')->set($data);
5356
printf('Set multiple data-type data for the one document in the data collection.' . PHP_EOL);

0 commit comments

Comments
 (0)