Miksus / red-bird

Repository Patterns for Python
https://red-bird.readthedocs.io
MIT License
163 stars 22 forks source link

ENH: id_field from model #38

Closed Miksus closed 1 year ago

Miksus commented 1 year ago

This PR introduces an option to specify the id_field with the model itself:

class MyItem(BaseModel):
    __id_field__ = "name"
    name: str
    ...

repo = Repo(model=MyItem)
assert repo.id_field == "name"

This makes it slightly easier to change the repository as needed.

codecov-commenter commented 1 year ago

Codecov Report

Base: 90.52% // Head: 90.58% // Increases project coverage by +0.05% :tada:

Coverage data is based on head (e1d29f0) compared to base (c0c8560). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #38 +/- ## ========================================== + Coverage 90.52% 90.58% +0.05% ========================================== Files 16 16 Lines 1024 1030 +6 ========================================== + Hits 927 933 +6 Misses 97 97 ``` | [Impacted Files](https://codecov.io/gh/Miksus/red-bird/pull/38?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli) | Coverage Δ | | |---|---|---| | [redbird/base.py](https://codecov.io/gh/Miksus/red-bird/pull/38/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cmVkYmlyZC9iYXNlLnB5) | `88.88% <100.00%> (+0.42%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.