Function: org-roam-backlinks-get

org-roam-backlinks-get is a byte-compiled function defined in org-roam-mode.el.

Signature

(org-roam-backlinks-get NODE &key UNIQUE)

Documentation

Return the backlinks for NODE.

 When UNIQUE is nil, show all positions where references are found.
 When UNIQUE is t, limit to unique sources.

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-mode.el
(cl-defun org-roam-backlinks-get (node &key unique)
  "Return the backlinks for NODE.

 When UNIQUE is nil, show all positions where references are found.
 When UNIQUE is t, limit to unique sources."
  (let* ((sql (if unique
                  [:select :distinct [source dest pos properties]
                   :from links
                   :where (= dest $s1)
                   :and (= type "id")
                   :group :by source
                   :having (funcall min pos)]
                [:select [source dest pos properties]
                 :from links
                 :where (= dest $s1)
                 :and (= type "id")]))
         (backlinks (org-roam-db-query sql (org-roam-node-id node))))
    (cl-loop for backlink in backlinks
             collect (pcase-let ((`(,source-id ,dest-id ,pos ,properties) backlink))
                       (org-roam-populate
                        (org-roam-backlink-create
                         :source-node (org-roam-node-create :id source-id)
                         :target-node (org-roam-node-create :id dest-id)
                         :point pos
                         :properties properties))))))