Edit/delete bookmarks feature

This commit is contained in:
2022-05-30 13:28:46 +09:30
parent 226fa4a143
commit 173474d23f
8 changed files with 117 additions and 4 deletions

View File

@@ -39,6 +39,16 @@ func (m *BookmarkManager) AddBookmark(bm *entity.Bookmark) error {
return nil
}
func (m *BookmarkManager) DeleteBookmark(bm *entity.Bookmark) error {
err := m.db.store.FindOne(bm, bolthold.Where("URL").Eq(bm.URL))
if err == bolthold.ErrNotFound {
return fmt.Errorf("bookmark does not exist")
}
m.db.store.DeleteMatching(bm, bolthold.Where("ID").Eq(bm.ID))
return nil
}
// ListBookmarks returns all bookmarks.
func (m *BookmarkManager) ListBookmarks() ([]entity.Bookmark, error) {
bookmarks := make([]entity.Bookmark, 0, 0)