Obsidian Dataview
Is an Obsidian plugin that allows you to you to database everything in a Vault.
Usage¶
- Official documentation
- Visual Query Builder
- Add a space
at the end of the command if it doesn't work
- Add a space
- Cheatsheet
Metadata¶
Are data about the data, like context
To add then in Obsidian
- key:: value right in the text
- In the Front Matter, in YAML
Types of metadata¶
- Explicit (user-defined in YAML): List of all data types
- Implicit related to the page
file.namefile.ctimefile.mtimefile.dayfile.tagsan array of all tags in note, with subtags broken down:#tag/1/Awill be[#tag, #tag/1, #tag/1/A]
- Implicit related to the task or list
Queries¶
Are done in a thing similar to SQL
In note¶
- Do a Markdown with
dataviewas languageTABLE key FROM XXXkeyis the key defined in the annotationxxxis to sort where it search
WHERE type = "person"SORT file.name ASC
Queries type¶
/```dataviewto start the query - without the/list: Create a list of all specified noteslist "File path: " + file.pathto add the file path after the note namelist list_indentedto add indented [[YAML#Lists]] sub-list defined as metadata
task: searches for all checkboxes-[ ]tableshows a table of various metadata field linked to a notetable fieldA, fieldBfor multiple metadata
from: Define where you get the notesfrom #tagfrom "folder/sub"from [noteA](../noteA "noteA")all notes with links coming intonoteAfrom [[]]is the self note
from outgoing([noteA](../noteA "noteA"))all notes with links coming out of (leaving)noteA- Operators
- And:
from #a and #b - Or:
from "Uni" or "Work" - Not:
from -#tag
- And:
where: to narrow down the list further using comparison operators- operators:
>,>=,<,<=,=,!= where file.size > 1000to have all big fileswhere !completeto show all notes without the complete metadata field
- operators:
sortto define which order to list the resultsort field asc/descsort field1 asc, field2 descfor multiple sorts
flattento unroll listsflatten list_indentedto have one row for each item inlist_indented, in every notes
group byto gather together results based on a field valuegroup by fieldAwill only show the different value offieldA, not the content inside each note- the
rowsobject allow you to access each notes table rows.file.name from #tag group by intensitygives a table of eachintensitywith thenameof each notes that have the corresponding intensity- Group by is difficult, so try to concatenate several groups with
+
/``` to start the query - without the/`
Functions¶
Goal is to evaluate whether something is true or false
- Reference page
- contains(key, value) will search in key for value
- regexmatch(pattern, string) with pattern the regex and string the string to be tested against (example: file.name)
Examples:
- list where contains(file.name, "2022") will return all notes with 2022 in the name
- GROUP BY split(tags[0],"/")[1] will extract from the 1st tag the 1st thing after /
Group by the 2nd sub-item of the #area tag (for example #area/a and #area/b)
GROUP BY "Task: " +
split(
filter(
tags,
(x) =>
startswith(x, "#area")
)[0], // extract only the 1st match
"/",
2 // stop at the 2nd split occurence
)[1] // extract only the 1st tag