question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

One-to-many relations

See original GitHub issue

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)?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dantownsendcommented, Sep 6, 2021

The best way to see how it all hangs together with FastAPI, is use piccolo asgi new (assuming it’s a new project). That includes some example endpoints.

0reactions
dantownsendcommented, Oct 17, 2022

@metakot We have a prototype for this in a PR - https://github.com/piccolo-orm/piccolo/pull/599. Hopefully will get it merged soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate One to Many Annotation Tutorial - Baeldung
As we have seen in section 2, we can specify a many-to-one relationship by using the @ManyToOne annotation. A many-to-one mapping means that ......
Read more >
OneToMany (Java EE 6 ) - Oracle Help Center
The OneToMany annotation may be used within an embeddable class contained within an entity class to specify a relationship to a collection of...
Read more >
Java Persistence/OneToMany - Wikibooks, open books for an ...
A OneToMany relationship in Java is where the source object has an attribute that stores a collection of target objects and if those...
Read more >
Many-to-one / one-to-many relations - typeorm - GitBook
Many-to-one / one-to-many is a relation where A contains multiple instances of B, but B contains only one instance of A. Let's take...
Read more >
Most efficient way to map a @OneToMany relationship with ...
@OneToMany relationship with JPA and Hibernate. Simply put, one-to-many mapping means that one row in a table is mapped to multiple rows in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found