(define (find-note tags words) ;; INPUTS: '(tags) (conc "SELECT distinct n.id, n.title FROM notes n LEFT JOIN notes_tags nt ON nt.note_id = n.id LEFT JOIN tags t ON nt.tag_id = t.id JOIN fulltext ft ON ft.docid = n.id WHERE 1=1") (if (not (equal? "" tags)) (conc "AND t.name in (" tags ")\n") "") (if (not (equal? "" words)) (conc "AND ft.fulltext MATCH '" words "'\n") "") ";"))