recreated json file handling as connector model, fixing #10 and introducing #8 and #7

This commit is contained in:
2025-04-28 00:18:22 +02:00
parent dc27197129
commit 9ea44933a6
3 changed files with 113 additions and 98 deletions

View File

@@ -41,6 +41,11 @@ class JSONConnector(Connector):
with open(self.json_file, "r") as f:
return json.load(f)
def get_all_sorted_by(self, field: str, reverse=False) -> list:
with open(self.json_file, "r") as f:
data = json.load(f)
return sorted(data, key=lambda k: k[field], reverse=reverse)
def get_by_id(self, record_id: int) -> dict:
data = self.get_all()
for record in data: