Skip to content

Commit

Permalink
[Implement🦾] user services implents
Browse files Browse the repository at this point in the history
  • Loading branch information
[esekyi] committed Aug 24, 2024
1 parent d1476f7 commit 14a89ad
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions app/services/user_services.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
from app.models.user import User
from app import db

def get_all_users():
return User.query.all()

def create_user(username, email):
user = User(username=username, email=email)
return user

def get_user_by_id(user_id):
return User.query.get(user_id)


def create_user(username, email, password_hash):
new_user = User(username=username, email=email, password_hash=password_hash)
return new_user


def update_user(user, email=None, password_hash=None):
if email:
user.email = email
if password_hash:
user.password_hash = password_hash
db.session.commit()


def delete_user(user):
db.session.delete(user)
db.session.commit()

0 comments on commit 14a89ad

Please sign in to comment.