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
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.name
file.ctime
file.mtime
file.day
file.tags
an array of all tags in note, with subtags broken down:#tag/1/A
will 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
dataview
as languageTABLE key FROM XXX
key
is the key defined in the annotationxxx
is to sort where it search
WHERE type = "person"
SORT file.name ASC
Queries type¶
/```dataview
to start the query - without the/
list
: Create a list of all specified noteslist "File path: " + file.path
to add the file path after the note namelist list_indented
to add indented [[YAML#Lists]] sub-list defined as metadata
task
: searches for all checkboxes-[ ]
table
shows a table of various metadata field linked to a notetable fieldA, fieldB
for multiple metadata
from
: Define where you get the notesfrom #tag
from "folder/sub"
from [noteA](../noteA "noteA")
all notes with links coming intonoteA
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 > 1000
to have all big fileswhere !complete
to show all notes without the complete metadata field
- operators:
sort
to define which order to list the resultsort field asc/desc
sort field1 asc, field2 desc
for multiple sorts
flatten
to unroll listsflatten list_indented
to have one row for each item inlist_indented
, in every notes
group by
to gather together results based on a field valuegroup by fieldA
will only show the different value offieldA
, not the content inside each note- the
rows
object allow you to access each notes table rows.file.name from #tag group by intensity
gives a table of eachintensity
with thename
of 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