MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / find

Method find

gridfs/asynchronous/grid_file.py:866–911  ·  view source on GitHub ↗

Find and return the files collection documents that match ``filter`` Returns a cursor that iterates across files matching arbitrary queries on the files collection. Can be combined with other modifiers for additional control. For example:: for grid_data i

(self, *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

864 raise NoFile(f"no file could be deleted because none matched filename {filename!r}")
865
866 def find(self, *args: Any, **kwargs: Any) -> AsyncGridOutCursor:
867 """Find and return the files collection documents that match ``filter``
868
869 Returns a cursor that iterates across files matching
870 arbitrary queries on the files collection. Can be combined
871 with other modifiers for additional control.
872
873 For example::
874
875 for grid_data in fs.find({"filename": "lisa.txt"},
876 no_cursor_timeout=True):
877 data = grid_data.read()
878
879 would iterate through all versions of "lisa.txt" stored in GridFS.
880 Note that setting no_cursor_timeout to True may be important to
881 prevent the cursor from timing out during long multi-file processing
882 work.
883
884 As another example, the call::
885
886 most_recent_three = fs.find().sort("uploadDate", -1).limit(3)
887
888 would return a cursor to the three most recently uploaded files
889 in GridFS.
890
891 Follows a similar interface to
892 :meth:`~pymongo.collection.Collection.find`
893 in :class:`~pymongo.collection.Collection`.
894
895 If a :class:`~pymongo.client_session.AsyncClientSession` is passed to
896 :meth:`find`, all returned :class:`~gridfs.grid_file.GridOut` instances
897 are associated with that session.
898
899 :param filter: Search query.
900 :param batch_size: The number of documents to return per
901 batch.
902 :param limit: The maximum number of documents to return.
903 :param no_cursor_timeout: The server normally times out idle
904 cursors after an inactivity period (10 minutes) to prevent excess
905 memory use. Set this option to True prevent that.
906 :param skip: The number of documents to skip before
907 returning.
908 :param sort: The order by which to sort results. Defaults to
909 None.
910 """
911 return AsyncGridOutCursor(self._collection, *args, **kwargs)
912
913 async def open_download_stream_by_name(
914 self, filename: str, revision: int = -1, session: Optional[AsyncClientSession] = None

Callers 1

Calls 1

AsyncGridOutCursorClass · 0.85

Tested by 1