def get_posts_by_blog_id(cls, blog_id): """get_posts_by_id(str) -> return(obj) Returns all posts that belong to a specific blog. """ return [cls(**post) for post in db.find('posts', {'blog_id':blog_id})]
def get_by_author_id(cls, author_id): """ Return a lists of blogs belong to a specific author with the id """ blogs = db.find(collections='blogs', query={'author_id': author_id}) return [cls(**blog) for blog in blogs ]