Benutzerverwaltung begonnen
This commit is contained in:
parent
d8ddc4c416
commit
c4d27a1187
7 changed files with 88 additions and 3 deletions
26
backend/hermes/app/repositories/user_repository.py
Normal file
26
backend/hermes/app/repositories/user_repository.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.models.user import User
|
||||
from app.schemas.user import UserCreate
|
||||
|
||||
|
||||
class UserRepository:
|
||||
|
||||
@staticmethod
|
||||
def get_all(db: Session):
|
||||
return db.query(User).all()
|
||||
|
||||
@staticmethod
|
||||
def create(db: Session, user: UserCreate):
|
||||
|
||||
db_user = User(
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
password_hash=user.password
|
||||
)
|
||||
|
||||
db.add(db_user)
|
||||
db.commit()
|
||||
db.refresh(db_user)
|
||||
|
||||
return db_user
|
||||
Loading…
Add table
Add a link
Reference in a new issue