Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support class relationships and foreign keys #305

Open
wmusial opened this issue Jun 22, 2023 · 2 comments
Open

Support class relationships and foreign keys #305

wmusial opened this issue Jun 22, 2023 · 2 comments
Labels
question Further information is requested

Comments

@wmusial
Copy link

wmusial commented Jun 22, 2023

datafiles package is great, but it stops short of providing support for object relationships and foreign keys. is that feature anywhere on the horizon? if not, would you be open to discussing it and providing guidance on how to implement it?

@jacebrowning
Copy link
Owner

jacebrowning commented Jun 23, 2023

That's an interesting idea. Perhaps you could provide some pseudocode of how it might look to use such a feature?

@jacebrowning jacebrowning changed the title class relationships and foreign keys Support class relationships and foreign keys Jan 5, 2024
@jacebrowning jacebrowning added the question Further information is requested label Jan 5, 2024
@ramibch
Copy link

ramibch commented Mar 7, 2024

Great package @jacebrowning, congrats!

This request could be done like this:

from dataclasses import dataclass

from datafiles import datafile


@datafile("parents/{self.name}/metadata.yml")
@dataclass
class Parent:
    name: str


@datafile("parents/{self.parent.name}/items/{self.name}/metadata.yml")
@dataclass
class Item:
    name: str
    parent: Parent
    count: int
    available: bool

It works fine for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants