def eq(self, value: Any) -> QueryExpression: return eq(self, value)
from enum import Enum from odmantic import Model, query class TreeKind(str, Enum): BIG = "big" SMALL = "small" class Tree(Model): name: str average_size: float kind: TreeKind Tree.kind == TreeKind.SMALL #> QueryExpression({'kind': {'$eq': 'small'}}) Tree.kind.eq(TreeKind.SMALL) #> QueryExpression({'kind': {'$eq': 'small'}}) query.eq(Tree.kind, TreeKind.SMALL) #> QueryExpression({'kind': {'$eq': 'small'}})
from odmantic import Model, query class Tree(Model): name: str average_size: float Tree.name == "Spruce" #> QueryExpression({'name': {'$eq': 'Spruce'}}) Tree.name.eq("Spruce") #> QueryExpression({'name': {'$eq': 'Spruce'}}) query.eq(Tree.name, "Spruce") #> QueryExpression({'name': {'$eq': 'Spruce'}})
async def test_eq(engine: AIOEngine): query = cast(QueryExpression, PersonModel.first_name == "Michel") assert query == eq(PersonModel.first_name, "Michel") count = await engine.count(PersonModel, query) assert count == 1