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
def delete_post(post_id: str): post = Post.objects(pk=post_id).first() if post: post.delete() return True return False
def get_post(post_id): try: post = Post.objects(pk=post_id).first() return post except: 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