-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
40 lines (26 loc) · 798 Bytes
/
db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import NamedTuple, Optional, Protocol
from cassandra.cluster import uuid
class Book(NamedTuple):
id: uuid.UUID
title: str
author: str
class Reservation(NamedTuple):
id: uuid.UUID
book_id: uuid.UUID
email: str
class DB(Protocol):
def select_all_books(self) -> list[Book]:
...
def select_books_by_ids(self, book_ids) -> list[Book]:
...
def select_reservation_by_book(self, book_id) -> Optional[Reservation]:
...
def select_all_reservations(self) -> list[Reservation]:
...
def select_reservation_by_id(self, res_id) -> Optional[Reservation]:
...
# Write methods
def delete_reservation(self, res_id):
...
def add_new_reservation(self, book_id, email) -> bool:
...