I want to retrieve some pages that contain some metada, but for some reason the where and the include is not working. any insight on what I’m doing wrong will be helpful.
I have the following metadata:
one file:
colors:
- "[[blue]]"
- "[[yellow]]"
in different page im trying the following dataviewjs:
dv.table(["Contain Blue: ",""], dv.pages()
.where(f => f.colors.includes("Blue")) // I also tied here with f.colors.includes("[[Blue]]")) and to use == instead of includes.
.sort( s => s.file.link)
.map((m) => [m.file.link])
)
unfortunately none of them seems to work.
any idea?
You’ve got multiple issues in that code segment which needs to be addressed:
first and foremost you need to verify that colors exist before trying to read its value. Remember that dv.pages() initially starts out with every page of your vault. So you need to change the where clause to something like f.colors && f.colors.includes("Blue")
colors is also an array of links, so it might not work doing a simple includes()
it might also not work to check for “Blue” when your value is “blue”
I don’t have time to write it out fully, but hopefully this should get you (or someone else with better time) going to get your issue solved.