Skip to content

One-to-many relations #220

Description

@McSlow

Hi,
i'm currently having some beginner issues with one-to-many relations. Given the following scheme:

class Manager(Table):
    id = PrimaryKey()
    name = Varchar()

class Band(Table):
    id = PrimaryKey()
    name = Varchar()
    manager = ForeignKey(references=Manager)
    popularity = Integer()

How can I access all Bands a Manager manages?
So something like bandsAManagerManages = Manager.bands
Is there some automatic support for such things or do I need to write a function with a subquery in the Manager table (... .where(manager=self.id)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions