Listing notes with inlinks not already in the outlinks (all notes, not the current note)

What I’m trying to do

Using dataview, I have the following code to get all the inlinks in my notes that aren’t already in the oulinks of that note.

Table without ID
	file.link as "Other notes related",
	file.mtime as "Last Updated"
FROM [[]] and !outgoing([[]])
SORT file.mtime ASC

This helps to review notes and create relations viewing the inlinks that aren’t already in the note.

Now I would like to keep track of all these notes that happen to have inlinks that aren’t included in the outlinks, in my homepage. but i can’t get to make it work.

Things I tried

I tried this code, but it shows me all notes that don’t have the same amount of inlinks and outlinks, not only the ones that have inlinks not included in the outlinks. I don’t know if this is possible to get with dataview. Any help?

Table without ID
	file.link as "Notes that need to be reviewed",
	file.mtime as Last updated"
WHERE file.inlinks != file.outlinks

I’m not quite sure I truly get your use case, but the following queries show a method of matching the contents of file.inlinks and file.outlinks in various ways.

The first query just list the full in- and outlinks of my test files, and one can see in the output that M#_B are used for the missing inlinks, and M#_C are used for the missing outlinks.

The second and third query uses filter on either variant, and filter it against the other table only keeping those not in the other list.

## My test setup

```dataview
TABLE file.inlinks as IN, file.outlinks as OUT
WHERE file.folder = this.file.folder
  AND startswith(file.name, "t70495")
```

## Check for missing inlinks

```dataview
TABLE missingIn
WHERE file.folder = this.file.folder
  AND startswith(file.name, "t70495")
FLATTEN filter(file.outlinks, (o) => !contains(file.inlinks, o)) as missingIn
```

## Check for missing outlinks

```dataview
TABLE missingOut
WHERE file.folder = this.file.folder
  AND startswith(file.name, "t70495")
FLATTEN filter(file.inlinks, (i) => !contains(file.outlinks, i)) as missingOut
```

And the output is as follows:

You’ll of course need to change the WHERE ... AND clause to match your file set, but the important part is the FLATTEN line using the filter() statements to do the matching.

Another alternative could be to use map() a little similar to the filter() method in combination with either any(), all() or none(). But I do believe that one of this filter() versions is what you’re looking for.

Description of test file setup

The general idea for my test file setup is that the “t70495_M#…" files are my MOC files, and the "M##” are the content files belonging to that MOC. Some of the “M#_B” files don’t have links back to the MOC, and some of the “M#_C” are not linked to from the MOC.

Here is the full description of links from the “M4” set:

  • “t70595_M4_Missing a bit of both” links to “M4_A” and “M4_B”
  • “M4_A” links back to “t70495_M4…”
  • “M4_B” don’t have links
  • “M4_C” links back to “t70495_M4…”

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.