def get(self, id): load_options = subqueryload(Author.books) author = Author.find_or_fail(id, load_options=load_options) data = author.json() data['books'] = [book.json() for book in author.books] return data
def put(self, id): author = Author.find_or_fail(id) data = self.parser.parse_args() for key, value in data.items(): setattr(author, key, value) author.save() return author.json()
def delete(self, id): author = Author.find_or_fail(id) author.delete() return None, 204