Пример #1
0
def delete_comments_by_post(post_id: str):
    post = Post.objects(pk=post_id)
    if post:
        comments = Comment.objects(post_id=post_id)
        for comment in comments:
            comment.delete()
            return True
    return False
Пример #2
0
def delete_post(post_id: str):
    post = Post.objects(pk=post_id).first()
    if post:
        post.delete()
        return True
    return False
Пример #3
0
def get_post(post_id):
    try:
        post = Post.objects(pk=post_id).first()
        return post
    except:
        return False
Пример #4
0
def get_posts_by_author(author: str):
    if User.objects(user_name=author).first():
        posts = Post.objects(author=author)
        return posts
    return False