|
22 | 22 | _item_to_document_ref, |
23 | 23 | ) |
24 | 24 | from google.cloud.firestore_v1 import async_query |
25 | | -from google.cloud.firestore_v1.watch import Watch |
26 | | -from google.cloud.firestore_v1 import async_document |
27 | 25 |
|
28 | 26 |
|
29 | 27 | class AsyncCollectionReference(BaseCollectionReference): |
@@ -119,7 +117,8 @@ async def list_documents(self, page_size=None): |
119 | 117 | }, |
120 | 118 | metadata=self._client._rpc_metadata, |
121 | 119 | ) |
122 | | - return (_item_to_document_ref(self, i) for i in iterator) |
| 120 | + async for i in iterator: |
| 121 | + yield _item_to_document_ref(self, i) |
123 | 122 |
|
124 | 123 | async def get(self, transaction=None): |
125 | 124 | """Deprecated alias for :meth:`stream`.""" |
@@ -161,36 +160,3 @@ async def stream(self, transaction=None): |
161 | 160 | query = async_query.AsyncQuery(self) |
162 | 161 | async for d in query.stream(transaction=transaction): |
163 | 162 | yield d |
164 | | - |
165 | | - def on_snapshot(self, callback): |
166 | | - """Monitor the documents in this collection. |
167 | | -
|
168 | | - This starts a watch on this collection using a background thread. The |
169 | | - provided callback is run on the snapshot of the documents. |
170 | | -
|
171 | | - Args: |
172 | | - callback (Callable[[:class:`~google.cloud.firestore.collection.CollectionSnapshot`], NoneType]): |
173 | | - a callback to run when a change occurs. |
174 | | -
|
175 | | - Example: |
176 | | - from google.cloud import firestore_v1 |
177 | | -
|
178 | | - db = firestore_v1.Client() |
179 | | - collection_ref = db.collection(u'users') |
180 | | -
|
181 | | - def on_snapshot(collection_snapshot, changes, read_time): |
182 | | - for doc in collection_snapshot.documents: |
183 | | - print(u'{} => {}'.format(doc.id, doc.to_dict())) |
184 | | -
|
185 | | - # Watch this collection |
186 | | - collection_watch = collection_ref.on_snapshot(on_snapshot) |
187 | | -
|
188 | | - # Terminate this watch |
189 | | - collection_watch.unsubscribe() |
190 | | - """ |
191 | | - return Watch.for_query( |
192 | | - self._query(), |
193 | | - callback, |
194 | | - async_document.DocumentSnapshot, |
195 | | - async_document.AsyncDocumentReference, |
196 | | - ) |
0 commit comments