Example #1
0
 class ManyEntityHolder(Entity):
     name: str
     entities: t.List[SomeEntity] = Relationship(
         entity_type=SomeEntity,
         many=True,
         relation_type=RelationType.CHILD,
     )
Example #2
0
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')
Example #3
0
 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
Example #4
0
class User(Entity):
    name: str
    address: Address = Relationship(
        entity_type=Address,
        relation_type=RelationType.PARENT,
    )
Example #5
0
class Address(Entity):
    street: str
    user: '******' = Relationship(entity_type='User')
Example #6
0
class SomeEntity(Entity):
    id: int = Field(pk=True)
    name: str
    holder: 'EntityHolder' = Relationship(entity_type='EntityHolder')
Example #7
0
 class EntityHolder(Entity):
     name: str
     entity: SomeEntity = Relationship(entity_type=SomeEntity)
Example #8
0
 class EntityHolder(Entity):
     name: str
     entity: SomeEntity = Relationship(
         entity_type=SomeEntity,
         relation_type=RelationType.CHILD,
     )