Comparators#
This shows all the comparison objects and usages.
All of these classes are importable from alaric.comparison
Equality#
- class alaric.comparison.EQ(field: str, value: int | str | float | bytes | dict | ObjectId)#
Asserts the provided field is equal to the provided value.
- Parameters:
Notes
This also works on matching items in arrays in an OR based matching approach.
Lets match a document with an
_id
equal to1
from alaric import AQ from alaric.comparison import EQ query = AQ(EQ("_id", 1))
Contains#
- class alaric.comparison.IN(field: str, value: list | tuple | set)#
Asserts the provided field is within the provided values.
This class can be used in conjunction with
alaric.meta.NEGATE
- Parameters:
Lets match all documents where the field
counter
is equal to any number in this list.from alaric import AQ from alaric.comparison import IN query = AQ(IN("counter", [1, 3, 5, 7, 9]))
Existence#
Note
EXISTS
is still exported for backwards compatibility reasons.
- class alaric.comparison.Exists(field: str)#
Returns all documents that contain this field.
This class can be used in conjunction with
NEGATE
- Parameters:
field (str) – The field to check in.
Lets match all documents where the field
prefix
existsfrom alaric import AQ from alaric.comparison import EXISTS query = AQ(EXISTS("prefix"))
Greater then#
- class alaric.comparison.GT(field: str, value: int | str | float | bytes)#
Asserts the provided field is greater to the provided value.
This class can be used in conjunction with
NEGATE
- Parameters:
Lets match all documents where the field
counter
is greater then 5.from alaric import AQ from alaric.comparison import GT query = AQ(GT("counter", 5))
Less then#
- class alaric.comparison.LT(field: str, value: int | str | float | bytes)#
Asserts the provided field is less to the provided value.
This class can be used in conjunction with
NEGATE
- Parameters:
Lets match all documents where the field
counter
is less then 5.from alaric import AQ from alaric.comparison import LT query = AQ(LT("counter", 5))