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