class ManyEntityHolder(Entity): name: str entities: t.List[SomeEntity] = Relationship( entity_type=SomeEntity, many=True, relation_type=RelationType.CHILD, )
class Item(Entity): id: int items: t.List['Item'] = Nested( entity_type='Item', back_relation=True, many=True, default=list, ) parent: 'Item' = Relationship(entity_type='Item')
class Item(Entity): id: int = Field(pk=True) items: t.List['Item'] = Nested( # noqa: F821 entity_type='Item', many=True, back_relation=True, default=list, ) parent: 'Item' = Relationship(entity_type='Item') # noqa: F821
class User(Entity): name: str address: Address = Relationship( entity_type=Address, relation_type=RelationType.PARENT, )
class Address(Entity): street: str user: '******' = Relationship(entity_type='User')
class SomeEntity(Entity): id: int = Field(pk=True) name: str holder: 'EntityHolder' = Relationship(entity_type='EntityHolder')
class EntityHolder(Entity): name: str entity: SomeEntity = Relationship(entity_type=SomeEntity)
class EntityHolder(Entity): name: str entity: SomeEntity = Relationship( entity_type=SomeEntity, relation_type=RelationType.CHILD, )