Moved code to subfolder
This commit is contained in:
18
backend/database/database.py
Normal file
18
backend/database/database.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import List
|
||||
from models.request import Request
|
||||
|
||||
|
||||
request_collection = Request
|
||||
|
||||
|
||||
async def add_request(item: Request) -> Request:
|
||||
return await item.create()
|
||||
|
||||
async def retrieve_requests() -> List[Request]:
|
||||
return await request_collection.all().to_list()
|
||||
|
||||
async def retrieve_request(text: str, language_from: str, language_to: str) -> List[Request]:
|
||||
return await request_collection.find({"requested_text": text, "language_from": language_from, "language_to": language_to}).to_list()
|
||||
|
||||
async def clear_requests() -> None:
|
||||
return await request_collection.delete_all()
|
Reference in New Issue
Block a user