Enough for today

This commit is contained in:
lvrossem
2023-03-27 23:19:59 +02:00
parent 765f3e9bef
commit fc63176642
9 changed files with 80 additions and 52 deletions

View File

@@ -1,23 +1,22 @@
from sqlalchemy.orm import Session
from models import User, HighScore, CourseProgress
from . import models, schemas
import schemas, models
def get_user(db: Session, user_id: int):
return db.query(models.User).filter(models.User.id == user_id).first()
return db.query(models.User).filter(models.User.user_id == user_id).first()
def get_user_by_username(db: Session, username: str):
return db.query(User).filter(User.email == email).first()
return db.query(User).filter(models.User.username == username).first()
def get_users(db: Session, skip: int = 0, limit: int = 100):
return db.query(User).all()
def get_users(db: Session):
return db.query(models.User).all()
def create_user(db: Session, username: str, hashed_password: str):
db_user = models.User(username=username, hashed_password=hashed_password)
def create_user(db: Session, user: schemas.users.UserCreate):
db_user = models.User(username=user.username, hashed_password=user.hashed_password)
db.add(db_user)
db.commit()
db.refresh(db_user)