neosqlite.query_operators module

neosqlite.query_operators._get_nested_field(field: str, document: dict[str, Any]) Any[source]

Get a nested field value from a document using dot notation.

Parameters:
  • field (str) – The field path using dot notation (e.g., “profile.age”).

  • document (dict[str, Any]) – The document to get the field value from.

Returns:

The field value, or None if the field doesn’t exist.

Return type:

Any

neosqlite.query_operators._get_int_value(field: str, document: dict[str, Any]) int | None[source]

Get field value and convert to int, returning None if not possible.

Parameters:
  • field (str) – The document field to get.

  • document (dict[str, Any]) – The document to get the value from.

Returns:

The integer value, or None if conversion fails.

Return type:

int | None

neosqlite.query_operators._convert_to_bitmask(value: Any) int | None[source]

Convert a value to a bitmask using pattern matching.

Handles: - int: Direct integer bitmask - list/tuple: Array of bit positions - Other iterables: Iterable of bit positions - Other: Try to convert to int

Parameters:

value – The value to convert.

Returns:

The bitmask, or None if conversion fails.

Return type:

int | None

neosqlite.query_operators._eq(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the equals operator.

MongoDB semantics: {field: {$eq: value}} matches if: - The field value equals the value (scalar-to-scalar or array-to-array) - The field is an array containing the value (array contains element)

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value equals the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._gt(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the greater than operator.

MongoDB semantics: match if ANY array element satisfies the condition.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is greater than the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._lt(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the less than operator.

MongoDB semantics: match if ANY array element satisfies the condition.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is less than the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._gte(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the greater than or equal to operator.

MongoDB semantics: match if ANY array element satisfies the condition.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is greater than or equal to the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._lte(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the less than or equal to operator.

MongoDB semantics: match if ANY array element satisfies the condition.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is less than or equal to the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._all(field: str, value: list[Any], document: dict[str, Any]) bool[source]

Check if all elements in an array field match the provided value.

Parameters:
  • field (str) – The document field to compare.

  • value (list[Any]) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if all elements in the array field match the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._in(field: str, value: list[Any], document: dict[str, Any]) bool[source]

Check if a field value is present in the provided list.

Parameters:
  • field (str) – The document field to compare.

  • value (list[Any]) – The list to check against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is present in the list, False otherwise.

Return type:

bool

neosqlite.query_operators._ne(field: str, value: Any, document: dict[str, Any]) bool[source]

Compare a field value with a given value using the not equal operator.

MongoDB semantics: {field: {$ne: value}} matches if: - The field value does not equal the value (scalar-to-scalar or array-to-array) - The field is an array NOT containing the value (array does not contain element)

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The value to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is not equal to the given value, False otherwise.

Return type:

bool

neosqlite.query_operators._nin(field: str, value: list[Any], document: dict[str, Any]) bool[source]

Check if a field value is not present in the provided list.

Parameters:
  • field (str) – The document field to compare.

  • value (list[Any]) – The list to check against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value is not present in the list, False otherwise.

Return type:

bool

neosqlite.query_operators._mod(field: str, value: list[int], document: dict[str, Any]) bool[source]

Compare a field value with a given value using the modulo operator.

Parameters:
  • field (str) – The document field to compare.

  • value (list[int]) – The divisor and remainder to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value modulo the divisor equals the remainder, False otherwise.

Return type:

bool

neosqlite.query_operators._exists(field: str, value: bool, document: dict[str, Any]) bool[source]

Check if a field exists in the document.

Parameters:
  • field (str) – The document field to check.

  • value (bool) – True if the field must exist, False if it must not exist.

  • document (dict[str, Any]) – The document to check the field in.

Returns:

True if the field exists (if value is True), or does not exist (if value is False), False otherwise.

Return type:

bool

neosqlite.query_operators._regex(field: str, value: Any, document: dict[str, Any], options: str = '') bool[source]

Match a field value against a regular expression.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – The regular expression to compare against (str or re.Pattern).

  • document (dict[str, Any]) – The document to compare the field value from.

  • options (str) – Optional regex flags (i, m, x, s).

Returns:

True if the field value matches the regular expression, False otherwise.

Return type:

bool

neosqlite.query_operators._elemMatch(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if a field value matches all criteria in a provided dictionary or simple value.

Parameters:
  • field (str) – The document field to compare.

  • value (Any) – Either a simple value to match directly, a dictionary of query operators (e.g., {“$gte”: 90}), or a dictionary of field-value pairs for arrays of objects.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value matches the criteria, False otherwise.

Return type:

bool

neosqlite.query_operators._apply_query_operators(operators: dict[str, Any], value: Any) bool[source]

Apply query operators to a single value.

Parameters:
  • operators – Dictionary of query operators (e.g., {“$gte”: 90})

  • value – The value to test against

Returns:

True if all operators match, False otherwise

Return type:

bool

neosqlite.query_operators._size(field: str, value: int, document: dict[str, Any]) bool[source]

Check if the size of an array field matches a specified value.

Parameters:
  • field (str) – The document field to compare.

  • value (int) – The size to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the size of the array field matches the specified value, False otherwise.

Return type:

bool

neosqlite.query_operators._contains(field: str, value: str, document: dict[str, Any]) bool[source]

Check if a field value contains a specified substring.

Parameters:
  • field (str) – The document field to compare.

  • value (str) – The substring to compare against.

  • document (dict[str, Any]) – The document to compare the field value from.

Returns:

True if the field value contains the specified substring, False otherwise.

Return type:

bool

neosqlite.query_operators._type(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if field is of specified type.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – The type to check against (as a number, type object, or string name).

  • document (dict[str, Any]) – The document to check the field value from.

Returns:

True if the field is of the specified type, False otherwise.

Return type:

bool

neosqlite.query_operators._bits_all_clear(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if all specified bits are clear (0) in a numeric field. MongoDB $bitsAllClear operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if all specified bits are clear, False otherwise.

Return type:

bool

neosqlite.query_operators._bits_all_set(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if all specified bits are set (1) in a numeric field. MongoDB $bitsAllSet operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if all specified bits are set, False otherwise.

Return type:

bool

neosqlite.query_operators._bits_any_clear(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if any of the specified bits are clear (0) in a numeric field. MongoDB $bitsAnyClear operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if any of the specified bits are clear, False otherwise.

Return type:

bool

neosqlite.query_operators._bits_any_set(field: str, value: Any, document: dict[str, Any]) bool[source]

Check if any of the specified bits are set (1) in a numeric field. MongoDB $bitsAnySet operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if any of the specified bits are set, False otherwise.

Return type:

bool

neosqlite.query_operators._bitsAllClear(field: str, value: Any, document: dict[str, Any]) bool

Check if all specified bits are clear (0) in a numeric field. MongoDB $bitsAllClear operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if all specified bits are clear, False otherwise.

Return type:

bool

neosqlite.query_operators._bitsAllSet(field: str, value: Any, document: dict[str, Any]) bool

Check if all specified bits are set (1) in a numeric field. MongoDB $bitsAllSet operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if all specified bits are set, False otherwise.

Return type:

bool

neosqlite.query_operators._bitsAnyClear(field: str, value: Any, document: dict[str, Any]) bool

Check if any of the specified bits are clear (0) in a numeric field. MongoDB $bitsAnyClear operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if any of the specified bits are clear, False otherwise.

Return type:

bool

neosqlite.query_operators._bitsAnySet(field: str, value: Any, document: dict[str, Any]) bool

Check if any of the specified bits are set (1) in a numeric field. MongoDB $bitsAnySet operator.

Parameters:
  • field (str) – The document field to check.

  • value (Any) – Bitmask as integer, BinData, or array of bit positions.

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

Returns:

True if any of the specified bits are set, False otherwise.

Return type:

bool