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

Add relations to models #149

Open
3 tasks
ebebbington opened this issue Dec 2, 2021 · 1 comment
Open
3 tasks

Add relations to models #149

ebebbington opened this issue Dec 2, 2021 · 1 comment
Labels
Priority: Low Type: Chore This item introduces improvements or maintenance tasks

Comments

@ebebbington
Copy link
Member

Summary

What:

Add relations to each model, such as if a season belongs to a user, add a new user method to the model that gets the user based on the foreign key

also make base model return instances of each model instead of the raw row data

Why:

This way it’s super easy to get a users comments or users articles etc, querying the db and getting relations is made a lot easier

Acceptance Criteria

Below is a list of tasks that must be completed before this issue can be closed.

  • Write unit tests
  • Write integration tests
  • {add more checkboxes required by this issue as needed}
@ebebbington ebebbington added Type: Chore This item introduces improvements or maintenance tasks Priority: Low labels Dec 2, 2021
@ebebbington
Copy link
Member Author

Taking inspi from laravel, also add:

  1. Base model has abstract method: dummy()
  2. This creates a new row using placeholder data and returns the new row (as an instance of the model), used for testing (to quickly make new row sif needed, see laravel db factories, felt a whole new file was just pointless)
  3. method takes a generic object and will set props/fields based on the optional param
  4. implemented method will use a schema for the param, so typehints are provided and tsc errors can be produced when using it on each model (as each model has diff fields)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low Type: Chore This item introduces improvements or maintenance tasks
Development

No branches or pull requests

1 participant