diff options
Diffstat (limited to 'lisp/queries.lisp')
-rw-r--r-- | lisp/queries.lisp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lisp/queries.lisp b/lisp/queries.lisp index 4651ed6..2b43b78 100644 --- a/lisp/queries.lisp +++ b/lisp/queries.lisp @@ -68,10 +68,22 @@ (execute-non-query *db* (sql delete from "bookmark" where "url" = ?) url)) -(defun delete-tags (id) +(defun delete-tags (id &optional tags) "Clear the tags for bookmark with id ID." - (execute-non-query *db* (sql delete from "bookmark_tag" - where "bookmark_id" = ?) id)) + (if tags + (map nil + (lambda (tag) + (execute-non-query + *db* (sql delete from "bookmark_tag" + where "bookmark_id" = (select "rowid" + from "bookmark" + where "url" = ?) + and "tag_id" in (select "rowid" + from "tag" + where "name" = ?)) + id tag)) tags) + (execute-non-query *db* (sql delete from "bookmark_tag" + where "bookmark_id" = ?) id))) (defun get-bookmark-id (url) "Get the id of the bookmark for URL." |