How can I get a list of all the yaml fields I have defined over time (similar to tags list)?

I can be very forgetful and chaotic, which means I will create new yaml fields on the go and then forget about them. Later, when I want to query for something using dataview, I don’t know what fields to look for.

If there is a way, how can I list all the existing fields across all notes (just like I can list tags)?

```dataviewjs
const fields = {}
Object.values(app.metadataCache.metadataCache)
  .forEach(x => Object.keys(x.frontmatter || {})
  .forEach(y => fields[y] = true))

dv.list(Object.keys(fields))
```

Or more verbose with a count of how many times you’ve used the field:

```dataviewjs
const fields = {}
Object.values(app.metadataCache.metadataCache)
  .forEach(x => Object.keys(x.frontmatter || {})
  .filter(x => x !== 'position')
  .forEach(x => fields[x] = -~fields[x]))

dv.header(3, 'YAML fields')
dv.list(Object.keys(fields)
  .sort((a, b) => fields[b] - fields[a])
  .map(x => `${x} (${fields[x]} notes)`))
```
6 Likes

Thank you, that solves it!

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