This repository was archived by the owner on Mar 2, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
google/cloud/firestore_v1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,6 +112,23 @@ async def add(
112112 write_result = await document_ref .create (document_data , ** kwargs )
113113 return write_result .update_time , document_ref
114114
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+
115132 async def list_documents (
116133 self ,
117134 page_size : int = None ,
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ def test_query_method_matching(self):
5757 # ``AsyncCollectionReference``.
5858 self .assertLessEqual (query_methods , collection_methods )
5959
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+
6066 def test_constructor (self ):
6167 collection_id1 = "rooms"
6268 document_id = "roomA"
You can’t perform that action at this time.
0 commit comments