Example #1
0
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
Example #2
0
def get_posts_by_author(author: str):
    if User.objects(user_name=author).first():
        posts = Post.objects(author=author)
        return posts
    return False
Example #3
0
def delete_user(user_name: str) -> bool:
    user = User.objects(user_name=user_name).first()
    if user:
        user.delete()
        return True
    return False
Example #4
0
def get_user_by_email(email: EmailStr):
    user = User.objects(email=email).first()
    return user
Example #5
0
def get_user(user_name: str):
    user = User.objects(user_name=user_name).first()
    return user
Example #6
0
def get_users():
    users = User.objects()
    return users