RoamAlphaAPI datalog query to find nested pages and remove the nesting
v1
let queryText = `[:find ?title:name ?title:uid
:in $ ?searchString
:where [?page :node/title ?title:name]
[?page :block/uid ?title:uid]
[(clojure.string/includes? ?title:name ?searchString)]]`;
results = window.roamAlphaAPI.q(queryText, "[[");
for (let i = 0; i < results.length; i++) {
let title = results[i][0];
let uid = results[i][1];
console.log(title, uid);
title = title.replaceAll("[[", "");
title = title.replace("]]", "");
console.log(title);
/*window.roamAlphaAPI.data.page.update(
{"page":
{"title": title,
"uid": uid}}
);*/
}
v2 - This is hitting the rate limit for roam, need to use a sleep function
let queryText = `[:find ?title:name ?title:uid
:in $ ?searchString
:where [?page :node/title ?title:name]
[?page :block/uid ?title:uid]
[(clojure.string/includes? ?title:name ?searchString)]]`;
results = window.roamAlphaAPI.q(queryText, "~~");
for (let i = 0; i < results.length; i++) {
let title = results[i][0];
let uid = results[i][1];
console.log(title, uid);
title = title.replaceAll("~~", "");
await new Promise(r => setTimeout(r, 500));
//title = title.replace("]]", "");
console.log(title);
window.roamAlphaAPI.data.page.update(
{"page":
{"title": title,
"uid": uid}}
);/**/
}
await new Promise(r => setTimeout(r, 500));
RoamAlphaAPI function to export a block and it's children to markdow
v1
document view
more document
italic and bold
for
another
remove command