Bases: Access (the number of) incoming links (backlinks) of a file

Use case or problem

While I have already successfully replaced most my dataview-queries with Bases (I personally prefer native functions aka core plugins over community ones), I noticed that I currently cannot access the number of incoming/outgoing links of a file.

This was quite a cool function in dataview where I could sort files by the number of links the file contained via this syntax:

length(file.inlinks) as "in", length(file.outlinks) as "out"

Another cool function in dataview was this code to display all files that link to a note but are not linked backwards:
contains(this.file.inlinks, file.link) AND !contains(this.file.outlinks, file.link)

Proposed solution

I would love to have more information about the file such as the number of in-/outlinks available to us in Bases so that we can create even cooler Tables/Overviews!

Okay, so I managed to find a filter to get all the files that link to the current-file (the base is embedded in), but that are not linked back from the current file:

filters:
  and:
    - linksTo(file.file, this.file.path)
    - not:
        - linksTo(this.file.file, file.file)

Thats already great, but I would still love to find out how many files link to/from the current file :slight_smile:

2 Likes

This code no longer works with Obsidian v1.9.2 - the new working filter is:

filters:
  and:
    - file.hasLink(this.file)
    - not:
        - this.file.hasLink(file.file)

With the new functions/syntax in v1.9.2 it is now also possible to get the number of outgoing links from the current file with this formula:

file.links.length

So now the only thing still missing from my feature request is the ability to access the number of incoming links to the current file.

renamed for clarity

1 Like