back population

This commit is contained in:
Jörn-Michael Miehe 2022-03-23 15:30:22 +00:00
parent c4ad9a8e40
commit ac6e506486

View file

@ -24,10 +24,10 @@ class User(ORMBaseModel):
"UserCapability", lazy="joined", cascade="all, delete-orphan"
)
certificates: list[Certificate] = relationship(
"Certificate", lazy="select"
"Certificate", lazy="select", back_populates="owner"
)
distinguished_names: list[DistinguishedName] = relationship(
"DistinguishedName", lazy="select"
"DistinguishedName", lazy="select", back_populates="owner"
)
@classmethod
@ -69,6 +69,10 @@ class DistinguishedName(ORMBaseModel):
email = Column(String)
common_name = Column(String, nullable=False)
owner: User = relationship(
"User", lazy="joined", back_populates="distinguished_names"
)
UniqueConstraint(
country,
state,
@ -96,3 +100,7 @@ class Certificate(ORMBaseModel):
distinguished_name: DistinguishedName = relationship(
"DistinguishedName", lazy="joined"
)
owner: User = relationship(
"User", lazy="joined", back_populates="certificates"
)