def exists(model):
     return len(
         Database.read(
             """
     SELECT * FROM article_reverse_index
     WHERE article_id = ?
     AND word = ?
     """, [model['article_id'], model['word']])) > 0
Exemplo n.º 2
0
    def get(article_id):
        results = Database.read(
            """
        SELECT * FROM article
        WHERE id = ?
        """, [article_id])

        if len(results) > 0:
            return results[0]
        else:
            raise ItemNotFoundException()
 def get_for_user(user_id):
     return Database.read("""
     SELECT * FROM notification WHERE to_user = ?
     """, [user_id])
Exemplo n.º 4
0
 def get_outbox(user_id):
     return Database.read(
         """
     SELECT * FROM message WHERE from_user = ?
     """, [user_id])
Exemplo n.º 5
0
 def get_inbox(user_id):
     return Database.read(
         """
     SELECT * FROM message WHERE to_user = ?
     """, [user_id])
 def search(word):
     return Database.read(
         """
     SELECT * FROM article_reverse_index
     WHERE word = ?
     """, [word])
Exemplo n.º 7
0
 def get_all():
     return Database.read("SELECT * FROM user;", [])
Exemplo n.º 8
0
 def get(user_id):
     results = Database.read("SELECT * FROM user WHERE id = ?", [user_id])
     if len(results) > 0:
         return results[0]
     else:
         raise ItemNotFoundException()