I'm trying to create an entity architecture with SQLAlchemy and python Generics, i.e Model -> Repository -> API
I have the following User model:
class User(db.Model):
id
username
email
...
The following Repository code:
class UserRepository(Repository[User]):
pass
I'm trying to find a way that I could "access" the User model from within the Repository base class, something like:
T = TypeVar('T')
class Repository(Generic[T]):
@staticmethod
def get(id) -> T:
return T.query.filter(...)
Tried also going via db.session.query(...) without success.
Any ideas?
Thanks.