Dataview - list pages which have at least the same tags as the current page

What I’m trying to do

List all notes from a folder which have the tags of the current note.

Things I have tried

let subjects= dv.current().file.etags;
dv.table(["Ex.", "Subjects"], dv.pages('"folder"')
    .sort(es => es.file.link, 'asc')
    .map(es => [es.file.link, es.file.etags])
    .where(es => subjects.every(elem => es.file.etags.includes(elem) )))

But I receive the following error: Evaluation Error: TypeError: Cannot read properties of undefined (reading 'etags')

After your map() the chain doesn’t have the full page element anymore, just the elements you’ve mapped (aka the link and the tags themselves), and they’re now in an array and not an object.

So either you need to refer to the mapped data using something like:

.where(es => subjects.every(elem => es[1].includes(elem) )))

Or maybe simpler just swap the map() and the where() lines around.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.