Bases - How do you search for the absence of _any_ tag?

What I’m trying to do

I’m attempting to create a base that lists files that do not have any tags in the properties.

Things I have tried

This is the general inline block I’m working with:

filters:
	and:
		- file.hasTag() $this is the line that I'm changing$
views:
	- type: table
	  name: "Missing Tags"

using - file.hasTag("todo") finds all of my to-do files without issue, but I’m unsure how I can go about finding the absence of any tags (I know I can change the and: to not: to find all files that don’t have a specific tag).

YAML is not my strong-suite. In fact, I rather hate it. Please don’t judge. That said, I’ve tried these without success:

  • - file.hasTag()
  • - file.hasTag("")
  • - file.hasTag([])
  • - file.tags ==
  • - file.tags == ""
  • - file.tags == []
  • - file.tags == null
  • - file.tags == false

I’ve tried each of these with both and: and not:, just to test.

In addition to these, I’ve tried various !NOT lines, such as:

filters:
	and:
		- !file.hasTag()
views:
	- type: table
	  name: "Missing Tags"

Including:

  • !file.hasTag()
    = !hasTag()

and various permutations both with the and: and without, as well as all of the previously-listed versions such as “”, , null, etc.

If there’s a way to do a search for the absence of something in general I would greatly appreciate that information.

Thank you!

If you’re considering tags in the front matter and inline, any of these should do it:

  • file.tags.isEmpty()
  • !file.tags
  • “None of the following are true” :right_arrow: file.tags

If you don’t want to take into account inline tags:

  • tags.isEmpty()
  • note.tags.isEmpty()
  • “None of the following are true” :right_arrow: tags

… and possibly others.

3 Likes

I don’t know why I didn’t think of appending .isEmpty() in any of my attempts, especially since I saw numerous other x.y.is$thing$() examples in my searches, but using file.tags.isEmpty() was exactly what I needed. Thank you, and apologies on my error!

3 Likes

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