Associations¶
Association helpers provide descriptor-style convenience attributes for query expressions and model access.
ormdantic.association.association_proxy
¶
association_proxy(relationship, attribute)
Descriptor that proxies through a relationship attribute.
Source code in ormdantic/association.py
def __init__(self, relationship: str, attribute: str) -> None:
self.relationship = relationship
self.attribute = attribute
self.expression_func: Callable[[type[Any]], Any] | None = None
expression
¶
expression(func)
Attach a class-level query expression for this proxy.
Source code in ormdantic/association.py
def expression(self, func: Callable[[type[Any]], Any]) -> "association_proxy":
"""Attach a class-level query expression for this proxy."""
self.expression_func = func
return self
ormdantic.association.hybrid_property
¶
hybrid_property(func)
Create a hybrid attribute descriptor.
Source code in ormdantic/association.py
def hybrid_property(func: Callable[[Any], Any]) -> hybrid_attribute:
"""Create a hybrid attribute descriptor."""
return hybrid_attribute(func)