I would like to create a note called Journal Entries that contains a table that has a column called date (which is actually the file name) and a column called mentions (which is actually file.outlinks).
Further, I would like to exclude the daily template file from the query AND exclude the “Yesterday” and “Tomorrow” navigation links. Lastly, not sure if this matters, but “Yesterday” and “Tomorrow” are aliases for other journal notes. i.e.
While I have the basic query working and have successfully excluded the Daily Template file
I cant figure out how to exclude the Yesterday and Tomorrow links. I am using the following query, and have tried adding AND statements excluding the Yesterday and Tomorrow outlinks, but no luck
TABLE file.outlinks as "Mentions"
WHERE contains(type, "daily") AND file.name !="Daily Template"
SORT file.name DESC
Also, apologies, but I can’t figure out how to do code blocks on this forum, I will edit for clarity if somebody can advise.
I’ll work on renaming the file column header later, that shouldn’t be too difficult I’m hoping.
TABLE file.outlinks as “Mentions”
FROM
WHERE contains(type, “daily”) AND file.name !=“Daily Template” AND !contains(file.outlinks, "Yesterday") AND !contains(file.outlinks, "Tomorrow")
SORT file.name DESC
Assuming contains looks for that string and doesn’t require an exact match (which I think is accomplished by econtains), that should work right?
If that was legal syntax, that would totally eliminate entire files where either of the yesterday or tomorrow links existed. However, I don’t think that’ll work since file.outlinks is a list of links where you then compare them against a text value.
You’d rather want to do a filter() on the file.outlinks to remove those specific links. Potentially combined with some check to see if it’s anything left of the list. I can type up an example later on today, I think.
Ugh, you are right. I dont want to eliminate the file from the table, I want to eliminate the outlinks containing yesterday and today from showing in the output. Thanks f0r pointing that out.
Thank you for providing the next clue, I’ll have a look at the filter() functionality. I’m pretty ignorant of how all this stuff works, but I feel like I am making progress.
So a nice person from reddit was able to help me out. Query follows:
TABLE filter(file.outlinks, (x)=>
!contains(string(x), "Yesterday") AND
!contains(string(x), "Tomorrow")) AS "Mentions"
WHERE contains(type, "daily")
AND file.name !="Daily Template"
SORT file.name DESC
The documentation for the format function is available, but I was having problems wrapping my head around how to use it.
Another option for that filtration could be to do:
filter(file.outlinks, (o) =>
meta(o).display != "Yesterday" AND
meta(o).display != "Tomorrow" ) as "Mentions"
This pulls out the display variant of the link, and make sure it doesn’t equal neither “Yesterday” or “Tomorrow”.
Note that if you’d want either variant in combination with not showing entries without any mentions at all you need to do something like the following:
```dataview
TABLE Mentions
FLATTEN array(filter(file.outlinks, (o) =>
meta(o).display != "Yesterday" AND
meta(o).display != "Tomorrow")) as "Mentions"
WHERE contains(type, "daily") AND file.name != "Daily Template"
AND length(Mentions) > 0
```
Notice the usage of array(filter( ... ) ) to repopulate the list after doing the FLATTEN on it, which is needed in order to store the result into Mentions. This usage of FLATTEN (and array(filter( ... ))) allows for the result to used in WHERE clauses (like above) and other parts of the DQL query.