neosqlite.collection.query_engine.find_operations module

Find operations for the QueryEngine.

class neosqlite.collection.query_engine.find_operations.FindOperationsMixin(*args, **kwargs)[source]

Bases: QueryEngineProtocol

Mixin class providing find operations for QueryEngine.

find(filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None, hint: str | None = None, session: ClientSession | None = None) Cursor[source]

Query the database and retrieve documents matching the provided filter.

Parameters:
  • filter (dict[str, Any] | None) – A dictionary specifying the query criteria.

  • projection (dict[str, Any] | None) – A dictionary specifying which fields to return.

  • hint (str | None) – A string specifying the index to use.

  • session (ClientSession, optional) – A ClientSession for transactions.

Returns:

A cursor object to iterate over the results.

Return type:

Cursor

find_raw_batches(filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None, hint: str | None = None, batch_size: int = 100, session: ClientSession | None = None) RawBatchCursor[source]

Query the database and retrieve batches of raw JSON.

Similar to the find() method but returns a RawBatchCursor.

This method returns raw JSON batches which can be more efficient for certain use cases where you want to process data in batches rather than individual documents.

Parameters:
  • filter (dict[str, Any] | None) – A dictionary specifying the query criteria.

  • projection (dict[str, Any] | None) – A dictionary specifying which fields to return.

  • hint (str | None) – A string specifying the index to use.

  • batch_size (int) – The number of documents to include in each batch.

  • session (ClientSession, optional) – A ClientSession for transactions.

Returns:

RawBatchCursor instance.

find_one(filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None, hint: str | None = None, session: ClientSession | None = None) dict[str, Any] | None[source]

Find a single document matching the filter.

Parameters:
  • filter (dict[str, Any]) – A dictionary specifying the filter conditions.

  • projection (dict[str, Any]) – A dictionary specifying which fields to return.

  • hint (str) – A string specifying the index to use (not used in SQLite).

  • session (ClientSession, optional) – A ClientSession for transactions.

Returns:

A dictionary representing the found document,

or None if no document matches.

Return type:

dict[str, Any]

find_one_and_delete(filter: dict[str, Any], projection: dict[str, Any] | None = None, sort: list[tuple[str, int]] | None = None, session: ClientSession | None = None, **kwargs: Any) dict[str, Any] | None[source]

Find a single document and delete it.

Parameters:
  • filter (dict[str, Any]) – A dictionary specifying the filter criteria.

  • projection (dict[str, Any]) – A dictionary specifying which fields to return.

  • sort (list[tuple[str, int]]) – A list of (key, direction) pairs for sorting.

  • session (ClientSession, optional) – A ClientSession for transactions.

  • **kwargs – Additional keyword arguments.

Returns:

The document before it was deleted,

or None if not found.

Return type:

dict[str, Any] | None

find_one_and_replace(filter: dict[str, Any], replacement: dict[str, Any], projection: dict[str, Any] | None = None, sort: list[tuple[str, int]] | None = None, upsert: bool = False, return_document: bool = False, session: ClientSession | None = None, **kwargs: Any) dict[str, Any] | None[source]

Find a single document and replace it.

Parameters:
  • filter (dict[str, Any]) – A dictionary specifying the filter criteria.

  • replacement (dict[str, Any]) – The replacement document.

  • projection (dict[str, Any]) – A dictionary specifying which fields to return.

  • sort (list[tuple[str, int]]) – A list of (key, direction) pairs for sorting.

  • upsert (bool) – If True, perform an upsert if no document matches.

  • return_document (bool) – If True, return the updated document.

  • session (ClientSession, optional) – A ClientSession for transactions.

  • **kwargs – Additional keyword arguments.

Returns:

The document before or after replacement,

or None if not found.

Return type:

dict[str, Any] | None

find_one_and_update(filter: dict[str, Any], update: dict[str, Any], projection: dict[str, Any] | None = None, sort: list[tuple[str, int]] | None = None, upsert: bool = False, return_document: bool = False, array_filters: list[dict[str, Any]] | None = None, session: ClientSession | None = None, **kwargs: Any) dict[str, Any] | None[source]

Find and update a single document.

Parameters:
  • filter (dict[str, Any]) – A dictionary specifying the filter criteria.

  • update (dict[str, Any]) – A dictionary specifying the update operations.

  • projection (dict[str, Any]) – A dictionary specifying which fields to return.

  • sort (list[tuple[str, int]]) – A list of (key, direction) pairs for sorting.

  • upsert (bool) – If True, perform an upsert if no document matches.

  • return_document (bool) – If True, return the updated document.

  • array_filters (list[dict[str, Any]]) – Filters for array updates.

  • session (ClientSession, optional) – A ClientSession for transactions.

  • **kwargs – Additional keyword arguments.

Returns:

The original document (before update),

or None if no document was found and updated.

Return type:

dict[str, Any] | None

_abc_impl = <_abc._abc_data object>
_is_protocol = False