list from #meetings-conversations
where file.meeting.mtype =book-club
As expected, this listed the current file. I thought, great. But then I noticed, it listed two other non-book-club files too, so I tested my syntax like this:
list from #meetings-conversations
where file.meeting.mtype = NOT-book-club
To my surprise, the current file showed up in this list too, even though I’m asking for “NOT-book-club” which should not match with book-club.
If I use “book-club” in quotes like this:
list from #meetings-conversations
where meeting[mtype] = "book-club"
Then I get zero results. Huh.
I’ve tried dots, brackets, quotes, no quotes, all to no avail. Huh.
I have updated dataview plugin and am using Obsidian 0.15.4
Pretty sure I’m just not understanding a basic Thing.
What I’m trying to do
I wish to understand the proper query syntax to list all the files with the book-club value for the meeting type.
I want to understand how to nest fields, such as here with the type field nested inside the meeting field.
Can someone help me list all the files with file.meeting.mtype = “book-club” ? Thanks!
I think this should be in the documentation somewhere. They do not show how to use nested values. I’ll make it an issue on github. Thank you so much! I literally tried every combination it seems but the right one! Ha. story of my programming life with Obsidian… cheers
@wealthychef As well as Craig’s answer, the following version of the WHERE line also works for me:
WHERE meeting["mtype"] = "book-club"
Dataview does something fancy to support accessing nested fields with both the dot notation and the quoted indexing notation. The quotes are necessary if indexing.
Thanks for adding that, especially the clarification about quoting. I’d like to know more about the notation’s origins and meaning, but knowing how to use it is almost as good.
I know this is solved, but I have another question closely related, which is, why does leaving the quotes off match all files that have a meeting.mtype field at all? It feels like the lack of quotes is coercing the value of book-club to True and then coercing the string values to a boolean because of the query type. Am I making sense? I just like to know why why why
Agreed. In lieu of a better conceptual understanding, I did a little more experimentation.
Here is my YAML (I used key names that did not occur anywhere else in my vault so that I did not have to worry about using FROM to filter.)
---
mainKey:
keyIWant1: val1
keyIWant2: val2
---
Then I just made a giant table with different variations. Perhaps you have some more of your own to experiment with!
TABLE WITHOUT ID
mainKey,
mainKey.keyIWant1 AS "withDot",
mainKey["keyIWant1"] AS "withIndex",
mainKey.keyIWant1 = "val1" AS "equals 'val1'",
mainKey.keyIWant1 = val1 AS "equals val1",
keyIWant1 AS "subkey alone",
keyIWant1 = "val1" AS "subkey equals 'val1'?",
keyIWant1 = val1 AS "subkey equals val1?"
Results (reformatted to markdown):
mainKey
withDot
withIndex
equals ‘val1’
equals val1
subkey alone
subkey equals ‘val1’?
subkey equals val1?
keyIWant1: val1
keyIWant2: val2
val1
val1
true
false
–
false
true
Without quotes, val1 (or book-club) is treated as the name of a variable, which if it does not exist as a field name in your file will be some “falsey” (opposite of “truthy”, both apparently technical terms!) value like null or undefined. Not sure which in regular dataview. In the rightmost 3 rows of the table, I tried to access keyIWant1 directly, which does not work. So I get a blank when trying to display its value and internally it is “falsey” (null or undefined). That does not equal “val1”, clearly. But in the rightmost column I am asking if two “falsey” things are equal, and they are!
A correctly formatted field name like mainKey.keyIWant1 or mainKey["keyIWant1"] that has a value in your file will compare its value as you would expect. So in the middle of the table, “val1” = “val1” is true and “val1” = <something falsey> is false.