File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
google/cloud/firestore_v1 Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,23 @@ async def add(
112
112
write_result = await document_ref .create (document_data , ** kwargs )
113
113
return write_result .update_time , document_ref
114
114
115
+ def document (
116
+ self , document_id : str = None
117
+ ) -> async_document .AsyncDocumentReference :
118
+ """Create a sub-document underneath the current collection.
119
+
120
+ Args:
121
+ document_id (Optional[str]): The document identifier
122
+ within the current collection. If not provided, will default
123
+ to a random 20 character string composed of digits,
124
+ uppercase and lowercase and letters.
125
+
126
+ Returns:
127
+ :class:`~google.cloud.firestore_v1.document.async_document.AsyncDocumentReference`:
128
+ The child document.
129
+ """
130
+ return super (AsyncCollectionReference , self ).document (document_id )
131
+
115
132
async def list_documents (
116
133
self ,
117
134
page_size : int = None ,
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ def test_query_method_matching(self):
57
57
# ``AsyncCollectionReference``.
58
58
self .assertLessEqual (query_methods , collection_methods )
59
59
60
+ def test_document_name_default (self ):
61
+ client = _make_client ()
62
+ document = client .collection ("test" ).document ()
63
+ # name is random, but assert it is not None
64
+ self .assertTrue (document .id is not None )
65
+
60
66
def test_constructor (self ):
61
67
collection_id1 = "rooms"
62
68
document_id = "roomA"
You can’t perform that action at this time.
0 commit comments