Last active
May 24, 2024 05:24
-
-
Save dmgerman/9a1b1414c2f34ab34fb41d27b8a498b5 to your computer and use it in GitHub Desktop.
New Node Constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cl-defstruct (org-roam-node (:constructor org-roam-node-create) | |
(:constructor org-roam-node-create-from-db | |
(title aliases ; 2 | |
id file file-title level todo ; 5 | |
point priority scheduled deadline properties ;;5 | |
olp file-atime file-mtime tags refs)) ;;5 | |
(:copier nil)) | |
"A heading or top level file with an assigned ID property." | |
file file-title file-hash file-atime file-mtime ;5 | |
id level point todo priority ; 5 | |
scheduled deadline title properties olp ;5 | |
tags aliases refs) | |
(defun org-roam-node-list () | |
"Return all nodes stored in the database as a list of `org-roam-node's." | |
(let ((rows (org-roam-db-query | |
"SELECT | |
title, | |
aliases, | |
id, | |
file, | |
filetitle, | |
\"level\", | |
todo, | |
pos, | |
priority , | |
scheduled , | |
deadline , | |
properties , | |
olp, | |
atime, | |
mtime, | |
'(' || group_concat(tags, ' ') || ')' as tags, | |
refs | |
FROM | |
( | |
SELECT | |
id, | |
file, | |
filetitle, | |
\"level\", | |
todo, | |
pos, | |
priority , | |
scheduled , | |
deadline , | |
title, | |
properties , | |
olp, | |
atime, | |
mtime, | |
tags, | |
'(' || group_concat(aliases, ' ') || ')' as aliases, | |
refs | |
FROM | |
( | |
SELECT | |
nodes.id as id, | |
nodes.file as file, | |
nodes.\"level\" as \"level\", | |
nodes.todo as todo, | |
nodes.pos as pos, | |
nodes.priority as priority, | |
nodes.scheduled as scheduled, | |
nodes.deadline as deadline, | |
nodes.title as title, | |
nodes.properties as properties, | |
nodes.olp as olp, | |
files.atime as atime, | |
files.mtime as mtime, | |
files.title as filetitle, | |
tags.tag as tags, | |
aliases.alias as aliases, | |
'(' || group_concat(RTRIM (refs.\"type\", '\"') || ':' || LTRIM(refs.ref, '\"'), ' ') || ')' as refs | |
FROM nodes | |
LEFT JOIN files ON files.file = nodes.file | |
LEFT JOIN tags ON tags.node_id = nodes.id | |
LEFT JOIN aliases ON aliases.node_id = nodes.id | |
LEFT JOIN refs ON refs.node_id = nodes.id | |
GROUP BY nodes.id, tags.tag, aliases.alias ) | |
GROUP BY id, tags ) | |
GROUP BY id | |
"))) | |
(mapcan | |
(lambda (row) | |
(let ( | |
(all-titles (cons (car row) (nth 1 row))) | |
) | |
(mapcar (lambda (temp-title) | |
(apply 'org-roam-node-create-from-db (cons temp-title (cdr row)))) | |
all-titles) | |
)) | |
rows) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The database stores point as
pos
whereas the node struct stores it aspoint
.Without accounting for this name change the marker will fail.