Implement entity deletion

This commit is contained in:
aditya.chandel
2024-12-25 22:25:48 -07:00
parent b7531670bf
commit f27470b901
4 changed files with 139 additions and 29 deletions
@@ -54,6 +54,16 @@ export class BookService {
this.books.next(filteredBooks);
}
removeBooksFromShelf(shelfId: number): void {
const books = this.books.value.filter(book => {
if(book.shelves) {
book.shelves = book.shelves.filter(shelf => shelf.id !== shelfId);
}
return book;
})
this.books.next(books);
}
getBookById(bookId: number): Observable<Book | undefined> {
return this.books$.pipe(
map(books => books.find(book => book.id === bookId))