users and status working
This commit is contained in:
27
app/alchemy/contact.py
Normal file
27
app/alchemy/contact.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from sqlalchemy import String, Text, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, declared_attr
|
||||
|
||||
from .base import Base, bidirectional_relationship
|
||||
# noinspection PyProtectedMember
|
||||
from .status import StatusForeignKey
|
||||
from .user import Versioned
|
||||
|
||||
|
||||
__all__ = ["Contact"]
|
||||
|
||||
class Contact(StatusForeignKey, Versioned, Base):
|
||||
"""Contact"""
|
||||
|
||||
name: Mapped[str] = mapped_column(String(80), unique=True)
|
||||
address: Mapped[str | None] = mapped_column(String(253))
|
||||
notes: Mapped[str | None] = mapped_column(Text)
|
||||
|
||||
|
||||
class ContactForeignKey:
|
||||
"""Foreign Key Mixin for :py:class:`Contact`"""
|
||||
|
||||
contact_id: Mapped[int | None] = mapped_column(ForeignKey("contact.id"))
|
||||
|
||||
@declared_attr
|
||||
def contact(cls) -> Mapped["Contact"]:
|
||||
return bidirectional_relationship(cls, Contact)
|
||||
Reference in New Issue
Block a user