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

Method find

gridfs/asynchronous/grid_file.py:350–408  ·  view source on GitHub ↗

Query GridFS for files. 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_out in fs.find({"filename": "lisa.txt"},

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

Source from the content-addressed store, hash-verified

348 return None
349
350 def find(self, *args: Any, **kwargs: Any) -> AsyncGridOutCursor:
351 """Query GridFS for files.
352
353 Returns a cursor that iterates across files matching
354 arbitrary queries on the files collection. Can be combined
355 with other modifiers for additional control. For example::
356
357 for grid_out in fs.find({"filename": "lisa.txt"},
358 no_cursor_timeout=True):
359 data = grid_out.read()
360
361 would iterate through all versions of "lisa.txt" stored in GridFS.
362 Note that setting no_cursor_timeout to True may be important to
363 prevent the cursor from timing out during long multi-file processing
364 work.
365
366 As another example, the call::
367
368 most_recent_three = fs.find().sort("uploadDate", -1).limit(3)
369
370 would return a cursor to the three most recently uploaded files
371 in GridFS.
372
373 Follows a similar interface to
374 :meth:`~pymongo.collection.Collection.find`
375 in :class:`~pymongo.collection.Collection`.
376
377 If a :class:`~pymongo.client_session.AsyncClientSession` is passed to
378 :meth:`find`, all returned :class:`~gridfs.grid_file.GridOut` instances
379 are associated with that session.
380
381 :param filter: A query document that selects which files
382 to include in the result set. Can be an empty document to include
383 all files.
384 :param skip: the number of files to omit (from
385 the start of the result set) when returning the results
386 :param limit: the maximum number of results to
387 return
388 :param no_cursor_timeout: if False (the default), any
389 returned cursor is closed by the server after 10 minutes of
390 inactivity. If set to True, the returned cursor will never
391 time out on the server. Care should be taken to ensure that
392 cursors with no_cursor_timeout turned on are properly closed.
393 :param sort: a list of (key, direction) pairs
394 specifying the sort order for this query. See
395 :meth:`~pymongo.cursor.Cursor.sort` for details.
396
397 Raises :class:`TypeError` if any of the arguments are of
398 improper type. Returns an instance of
399 :class:`~gridfs.grid_file.GridOutCursor`
400 corresponding to this query.
401
402 .. versionchanged:: 3.0
403 Removed the read_preference, tag_sets, and
404 secondary_acceptable_latency_ms options.
405 .. versionadded:: 2.7
406 .. seealso:: The MongoDB documentation on `find <https://dochub.mongodb.org/core/find>`_.
407 """

Callers 6

find_oneMethod · 0.95
get_versionMethod · 0.45
delete_by_nameMethod · 0.45
_read_size_or_lineMethod · 0.45
_create_cursorMethod · 0.45

Calls 1

AsyncGridOutCursorClass · 0.85

Tested by

no test coverage detected