-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries.edn
77 lines (68 loc) · 2.2 KB
/
queries.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
:lq/espansoBlocksQuery
{:query [:find (pull ?b [*]) ?bcontent
:where
[?b :block/properties ?prop]
[(get ?prop :espanso-regex) ?trg]
[(missing? $ ?b :block/name)]
(or-join [?b ?bcontent ?prop]
(and
[?bc :block/parent ?b]
[?bc :block/content ?bcontent]
)
[(get ?prop :espanso-replace) ?bcontent]
)
]
:desc "find espanso blocks"}
:lq/property
{:query [:find (pull ?b [*])
:in $ ?prop ?prop-value %
:where
[(keyword ?prop) ?prop-k]
(property ?b ?prop-k ?prop-value)]
:desc "List all blocks that have property equal to property value"}
:lq/property-all
{:query [:find (pull ?b [*])
:where
[?b :block/properties _]
[(missing? $ ?b :block/name)]]
:desc "List all blocks that have properties"}
:lq/property-counts
{:parent :lq/property-all
:result-transform (fn [result]
(->> result
(map (fn [m] (zipmap (keys (:block/properties m)) (repeat 1))))
(apply merge-with +)
(sort-by val >)))
:desc "Counts for all block properties"}
:lq/has-property
{:query [:find (pull ?b [*])
:in $ ?ks %
:where
[(keyword ?ks) ?k]
(has-property ?b ?k)]
:desc "List blocks that have given property"}
:lq/task
{:query [:find (pull ?b [*])
:in $ ?markers %
:where
(task ?b ?markers)]
:default-args [#{"TODO" "DOING"}]
:usage "MARKER [& MARKERS]"
:args-transform (fn [args]
(set (map (comp clojure.string/upper-case name) args)))
:desc "Todos that contain one of the markers"}
:lq/content-search
{:query [:find (pull ?b [*])
:in $ ?query %
:where
(block-content ?b ?query)]
:desc "Full text search on :block/content"}
:lq/property-search
{:query [:find (pull ?b [*])
:in $ ?prop ?query %
:where
[(keyword ?prop) ?prop-k]
(property ?b ?prop-k ?prop-value)
[(clojure.string/includes? ?prop-value ?query)]]
:desc "Full text search on property"}}