Hello all, I am donating to Logseq since some time to support the development. However I am not actively using it and are still stuck with Obsidian and/or Notion since I am missing a good structure to organize my books and quotes.

I really want to switch but I can’t figure this out. For storing books that’s fine. I can create a page per book and give it some metadata that I can then use to filter and search. Like that:

Now however as you can see I’m writing quotes (Zitate in German) and my opinion on them (Meinung in German) in the book’s page.

And here comes the tricky part:

  • I want a general overview of all quotes that I can search
  • I want an overview of quotes per author (the author is in the page properties so it has to basically do something like "select all pages of typ = book where autor = author and collect all quotes on them (page reference #Zitate)"

In Notion I currently have a general database of quotes:

In each of these quotes there is my opinion written in the page.

And then there’s the book database that has dedicated book pages to it which look like this and reference the quotes coming from that page:

Those are generated automatically when creating a book since I use a template for that but I know that Logseq supports templates, too so that should be fine.

For looking up quotes by the author due to how databases in Notion work I could just filter for it in the quotes database. However I also do the same with the quotes in the author’s page that I am doing in the book’s page. Thus when I open up the page of an author I can instantly see all their books, their current status (if I have read them or not etc.) and all their quotes that I have stored:

So yeah I am trying to find some kind of structure since ages now within Logseq to be able to replicate something like that, solving my only issue that keeps me from switching. Maybe there is some way with queries but I haven’t found one. I also don’t want to rely on custom CSS since I want to have something that is natively working without eventually failing in the future for some reason.

  • autokludge@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 month ago

    I hope this helps, I’m not entirely sure what/how you want to search on the all quotes page, but there seems to be enough power with advanced queries to get you there.

    I tinkered a bit and seem to have found a way, but not sure how powerful the searching needs to be. The rule is overboard as it is showing some techniques for grabbing the data, transforming it and making a custom view. There are extra fields that aren’t used, but might be easier to update the :view to include extra fields as needed.

    #+BEGIN_QUERY
    {
      :title [:h3 "Author Quotes"]
        :inputs ["Anotherauthor"]          ; could be set to :current-page if included on the Authors page
        :query [
        :find (pull ?b [*]) ?p ?author ?rating ?topics ?pagecount
          :in $ ?authorquery            ; name of the input
          :keys block book author rating topics pagecount 
          :where 
          [?t :block/name "quote"]      ; id of [[Quote]]
          [?b :block/refs ?t ]          ; block referencing [[Quote]]
            [?b :block/page ?p]         ; get id of page
              [?b :block/page ?page]
                [?p :block/properties ?pageprops]
                  [(get ?pageprops :type) ?pagetype]
                    (or [(= ?pagetype "Book")] [(contains? ?pagetype "Book")])         ; is this a Book?
                      [(get ?pageprops :author) ?author]
                    (or [(= ?author ?authorquery)] [(contains? ?author ?authorquery)]) ; is this by input Author? -- comment out line to make all books
                      [(get ?pageprops :topics) ?topics]
                      [(get ?pageprops :pages) ?pagecount]
                      [(get ?pageprops :rating) ?rating]
        ]
          :result-transform (fn [result] 
              (for [row (sort-by :date result)] 
               (let [block-map (get row :block)
                current-properties (:block/properties block-map)
                block-page (:block/page block-map)
                book (:block/original-name block-page)
                authors (:author row)
                updated-properties (assoc current-properties   ; attach book properties to block
                  :booktitle book
                  :topics (:topics row)
                  :pagecount (:pagecount row) 
                  :rating (:rating row)
                  :author authors
                  )]
                (assoc block-map :block/properties updated-properties)
               ) ;end let
              ) ;end for
              ) ;end fn
          ;:view :pprint   ; raw data view for debugging
          :view (fn [rows] [:table   ; uncomment lines below to include author column
              [:thead [:tr 
              [:th "💬Quote"]
              [:th "📖Book"]
    ;          [:th "✏️Author"] 
              ]] [:tbody (for [r rows] [:tr
                [:td [:a 
                    {:href (str "#/page/" (get-in r [:block/uuid]))} 
                    (clojure.string/replace (get-in r [:block/content]) "#Quote" "")
                ]]
                [:td [:a 
                    {:href (str "#/page/" (clojure.string/replace (get-in (get-in r [:block/properties]) [:booktitle]) "/" "%2F"))} 
                    (clojure.string/replace (get-in (get-in r [:block/properties]) [:booktitle]) "Book/" "")
                ]]
    ;            [:td (for [author (get-in (get-in r [:block/properties]) [:author])]
    ;              [:span [:a 
    ;                {:href (str "#/page/" (clojure.string/replace (str author) "/" "%2F"))} 
    ;                (clojure.string/replace (str author) "Author/" ""
    ;                )] 
    ;                (if-not (= author (last (get-in (get-in r [:block/properties]) [:author]))) ", ")]
    ;            )]
              ])]
          ])
    }
    #+END_QUERY