Logical Combinators#

This shows all the logical objects and usages.

All of these classes are importable from alaric.logical

Or#

class alaric.logical.OR(*comparisons: ComparisonT | LogicalT | Buildable | List[ComparisonT | LogicalT | Buildable])#

Conduct a logical OR between all items passed to the constructor.

Lets build a check using a simple OR which will return all results the field my_field is either True OR a number in the list [1, 2, 3, 7, 8, 9]

1from alaric import AQ
2from alaric.logical import OR
3from alaric.comparison import EQ, IN
4
5query = AQ(OR(EQ("my_field", True), IN("my_field", [1, 2, 3, 7, 8, 9])))
build() Dict[str, List[Dict]]#

Return this instance as a usable Mongo filter.

And#

class alaric.logical.AND(*comparisons: ComparisonT | LogicalT | Buildable | List[ComparisonT | LogicalT | Buildable])#

Conduct a logical AND between all items passed to the constructor.

Lets build a query which returns all results where the field discord is equal to Skelmis#9135 and gamer_tag is equal to Skelmis

1from alaric import AQ
2from alaric.logical import AND
3from alaric.comparison import EQ
4
5query = AQ(AND(EQ("discord", "Skelmis#9135"), EQ("gamer_tag", "Skelmis")))
build() Dict[str, List[Dict]]#

Return this instance as a usable Mongo filter.

Not#

class alaric.logical.NOT(*comparisons: ComparisonT | LogicalT | Buildable | List[ComparisonT | LogicalT | Buildable])#

Invert the effect of a query expression.

This back-links to here

Lets find all items where my gamer_tag does NOT match Skelmis

1from alaric import AQ
2from alaric.logical import NOT
3from alaric.comparison import EQ
4
5query = AQ(NOT(EQ("gamer_tag", "Skelmis")))
build() Dict[str, List[Dict]]#

Return this instance as a usable Mongo filter.