Beispiel #1
0
 def get_article(self, query: models.Article, article_id: str):
     """ Get A Single article """
     try:
         data = query.filter(
             models.Article.article_id == article_id).first()
         return data
     except SQLAlchemyError as e:
         fastapi_logger.exception("get_article")
         return None
Beispiel #2
0
    def get_all_articles(self, query: models.Article, tag: str) -> Any:
        """ Get All Articles """
        try:
            data = query.order_by(models.Article.modified_timestamp.desc())

            if tag:
                looking_for = '%{0}%'.format(tag)
                data = query.filter(
                    cast(models.Article.tags, String).ilike(looking_for))

            return data
        except SQLAlchemyError as e:
            fastapi_logger.exception("get_all_articles")
            return None