I was not able to find a simple answer for non programmer to solve my problem. I like to exclude a folder (in my case /readwise and his subfolders) in a given query. What would be the code for that?
Specific:
I use the follow query out of ideaverse pro to see placeholder notes with at least 3 links pointing to it. But I can’t use the workflow cause it shows to much results that I don’t need because of a folder that should’nt be included. The code is the follow, but what do I have to implement, for leaving the readwise out of the results?
[!orbit]- #### Accreting placeholder notes with at least 3 links pointing to it
If you get the spark, turn the placeholder note into an actual note.
const count = 3;
let d = {};
function process(k, v) {
Object.keys(v).forEach(function (x) {
x = dv.fileLink(x);
if (d[x]==undefined) { d[x] = []; }
d[x].push(dv.fileLink(k));
});
}
Object.entries(dv.app.metadataCache.unresolvedLinks)
.filter(([k,v])=>Object.keys(v).length)
.forEach(([k,v]) => process(k, v));
dv.table(["Accreting placeholder notes", "Linked from"],
Object.entries(d)
.filter(([k, v]) => v.length >= count)
.sort((a, b) => b[1].length - a[1].length)
.map(([k,v])=> [k, v.join(" • ")]))
You can also think of these as: shadow seeds, secret slowburns, accreting placeholder notes
One way to hack this in without interfering too much with how your code works now would be to use dv.pages() to get a list of all pages that COULD be valid (ie, excluding that pesky folder) then checking all your fileLink paths against that list to see if you should proceed, but it feel a bit cart/horsey.
To exclude folder we got some options like @cheezopath says:
In a DQL query you do: FROM !"my/folder"
In dataviewjs you could do: dv.pages('!"my/folder"')
And in your script it’s a little bit more tricky , but we need to filter on the path using something like !path.startsWith("my/folder")
When it’s calling process(k, v) the k parameter is the full path to the note which links to the unresolved note, so this is one place we could check to exclude the folder. So if you replace the process(k, v) function with this:
function process(k, v) {
Object.keys(v).forEach(function (x) {
x = dv.fileLink(x);
if ( !k.startsWith("my/folder") ) {
if (d[x]==undefined) { d[x] = []; }
d[x].push(dv.fileLink(k));
}
});
}
The function above would exclude the my/folder from this particular search. This exclusion could also be done before we call the process(k, v), and then you’d replace the code below the function with this section (and you could keep the function as it was before):