neosqlite.collection.query_helper.positional_update module

Positional update operations for array elements.

neosqlite.collection.query_helper.positional_update._apply_positional_update(doc: dict[str, Any], field_path: str, value: Any, array_filters: list[dict[str, Any]] | None = None, filter_doc: dict[str, Any] | None = None) bool[source]

Apply an update to array elements using positional operators.

Supports: - $: First matching array element - $[]: All array elements - $[identifier]: Filtered array elements (requires arrayFilters)

Parameters:
  • doc – The document to update

  • field_path – The field path containing positional operator(s)

  • value – The value to set

  • array_filters – Optional list of filter documents for $[identifier]

  • filter_doc – The query filter document (for $ operator)

Returns:

True if update was applied, False otherwise

Return type:

bool

neosqlite.collection.query_helper.positional_update._apply_positional_recursive(doc: Any, parts: list[str], index: int, value: Any, array_filters: list[dict[str, Any]] | None = None, filter_doc: dict[str, Any] | None = None, parent_array: list[Any] | None = None) bool[source]

Recursively apply positional update through nested structures.

Parameters:
  • doc – Current document or sub-document

  • parts – Field path parts

  • index – Current part index

  • value – Value to set

  • array_filters – Filter documents for $[identifier]

  • filter_doc – Query filter for $ operator

  • parent_array – Parent array (for $ operator to know which array to update)

Returns:

True if update was applied

Return type:

bool

neosqlite.collection.query_helper.positional_update._matches_filter(elem: Any, filter_spec: dict[str, Any]) bool[source]

Check if an array element matches a filter specification.

Parameters:
  • elem – The array element to check

  • filter_spec – The filter specification (can be a dict with operators or a scalar value)

Returns:

True if element matches the filter

Return type:

bool

neosqlite.collection.query_helper.positional_update._matches_query_operators(value: Any, operators: dict[str, Any]) bool[source]

Check if a value matches query operators.

Parameters:
  • value – The value to check

  • operators – Dictionary of query operators

Returns:

True if value matches all operators

Return type:

bool

neosqlite.collection.query_helper.positional_update._set_nested_field(doc: dict[str, Any], field_path: str, value: Any) None[source]

Set a nested field value using dot notation.

Parameters:
  • doc – The document to update

  • field_path – Dot-notation field path (e.g., “a.b.c”)

  • value – The value to set