Bases: Filter by backlinks

What I’m trying to do

How to use `file.backlinks` ?

I don’t want to see any notes, which are mentioned in note Animals

Things I have tried

Advanced formula

!file.backlinks.containsAny("Animals")
!file.backlinks.containsAny(Animals)

You would need to use link("Animals") like this:

!file.backlinks.contains(link("Animals"))

However, the backlinks function can be “expensive” to run and doesn’t update automatically. A better option is:

!file("Animals").hasLink(file)

And if the base is in the “Animals” note, or if you want one base which applies the filter to any active note, then go with this filter:

!this.file.hasLink(file)

Thanks. It works!

I didn’t know that. Does that mean if I change the file named “Animals” the second filter gets automatically updated but not the first one?

Sort of. I left out the details.

file.backlinks and file.properties don’t auto-update, and file.backlinks is performance heavy, per the docs at Bases syntax - Obsidian Help. The docs recommend using file.links instead of file.backlinks where possible.

To see it in action, display file.backlinks in a base, delete (or add) a link in a note, and see that the base takes a while to update. Compare to how the base immediately updates for actions such as changing a note title.

It’s not documented that file.hasLink() doesn’t auto-update, but in my experience, it doesn’t. I have to wait or reload the base to see the change.

So to your question, from what I’ve seen, both of them don’t auto-update :frowning: . But only one is documented along with its performance drawbacks.

2 Likes