Trying to create queries based on lists within properties, using the dataview plugin.
I’m pretty new to this, so forgive my lack of knowledge. But I’ve got some properties for a bunch of dnd spells and one of them is logging what class can cast. I’ve been logging them like so
I’d like to hypothetically, only list spells that have “wizard” included, I can’t get this to work for some reason though, specifically from lists. Can anyone explain to me what I’m doing wrong? And if yall need more info I’m happy to provide.
ah HAH, that did it! Thanks so much, and thanks for that link. Querying language is a whole new concept for me so this helps immensely. Good to know about the # in the frontmatter too.
In playing around a little bit more, is there a way to pull from multiple results in the class list in this case? Like say I wanted to pull from classes that allow both wizards and artificers
LIST
FROM spell
WHERE contains(class, "wizard" "artificer")
that doesnt seem to work, but this works fine
LIST
FROM #spell
WHERE contains(class, "wizard")
WHERE contains(class, "artificer")
which is also fine, but if there is a way to consolidate that, it might be better.
in addition to that, how would I create a list that includes ALL wizard and ALL artificer spells? Not just the ones that both wizards and artificers can cast? My first instinct is to do something like this
LIST
FROM spell
WHERE contains(class, "wizard")
AND
WHERE contains(class, "artificer")
but again, errors.
im trying my hardest hahah like I said this is SUPER new to me, I don’t know anything about coding or logic like this so sorry if it’s all beginner stuff. Totally unfamiliar with this language and I want to wrap my head around it!
LIST
FROM #spell
WHERE contains(class, "wizard") AND contains(class, "artificer")
You still need the # in the from field of a query; you only drop it out of the yaml frontmatter.
You can string multiple WHERE conditions together with AND, which can be in a line or multiline if that makes it clearer to read
to get all wizard spells and all artificer spells you could use OR
LIST
FROM #spell
WHERE contains(class, "wizard") OR contains(class, "artificer")
ahhh that works amazingly! I’m gonna dig into some videos and see if I can’t make further sense of how dataview works, but this really helps me in the immediate. I think my thinking is in the right place but just knowing where to troubleshoot is where I stumble.
Thanks for your help! This’ll help a lot in the short term, excited to dig more into what dataview can do long term