Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from models.model import Book
class BookDB:
ID = 0
def __init__(self):
self.books = []
self.insert(Book('Don Quijote de la Mancha', 'Miguel de Cervantes'))
self.insert(Book('Romeo y Julieta', 'William Shakespeare'))
def insert(self,book):
self.ID+=1 = self.ID
def all(self):
return self.books
def one(self,bookId):
result = next(filter(lambda book: == bookId,self.books),None)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment