def delete_comments_by_author(author: str): user = User.objects(user_name=author) if user: comments = Comment.objects(author=author) for comment in comments: comment.delete() return True return False
def get_posts_by_author(author: str): if User.objects(user_name=author).first(): posts = Post.objects(author=author) return posts return False
def delete_user(user_name: str) -> bool: user = User.objects(user_name=user_name).first() if user: user.delete() return True return False
def get_user_by_email(email: EmailStr): user = User.objects(email=email).first() return user
def get_user(user_name: str): user = User.objects(user_name=user_name).first() return user
def get_users(): users = User.objects() return users