Watch the recording on YouTube!
https://store.systemcrafters.net
Today we'll take a look at the org-roam-db-query function which allows us to gather information about our notes and their connections to other notes.
This API actually queries a local SQLite database! We may have to look at the docs for emacsql to learn more of the options.
(require 'org-roam-node)
Take a look at org-roam-db.el, find the comment labelled "Schemata" (line 144).
There are functions for accessing columns like org-roam-node-tags.
There are a few useful ways to do this:
There are other useful functions in org-roam-db.el that we might look at if we have time!
Org Roam Manual: Accessing and Modifying Nodes
(defun my/org-roam-select-language ()
(interactive)
(org-roam-node-read
nil
(lambda (node)
(member "Language" (org-roam-node-tags node)))
(lambda (completion-a completion-b)
(< (length (org-roam-node-title (cdr completion-a)))
(length (org-roam-node-title (cdr completion-b)))))
t))
(require 'seq)
(defun my/org-roam-get-project-notes ()
(interactive)
(mapcar
#'org-roam-node-file
(seq-filter
(lambda (node)
(member "Project" (org-roam-node-tags node)))
(org-roam-node-list))))
(setq org-directory "~/RoamFiles")
(setq org-agenda-files (my/org-roam-get-project-notes))
EmacSQL readme: https://github.com/skeeto/emacsql
(defun my/org-roam-show-linked-agenda ()
(interactive)
(let ((node (org-roam-node-read))
(org-agenda-files))
(setq org-agenda-files
(cons (org-roam-node-file node)
(mapcar
(lambda (res)
(org-roam-node-file (org-roam-node-from-id (car res))))
(org-roam-db-query
[:select :distinct [dest]
:from links
:where (= source $s1)
:and (= type "id")]
(org-roam-node-id node)))))
(org-agenda)))
Showing node TODO state:
(setq org-roam-node-display-template "${title:*} ${todo:10} ${tags:20}")
Showing node deadline:
(setq org-roam-node-display-template "${title:*} Deadline: ${deadline:10} ${tags:20}")