Help dataviewJS query for metadata-menu plug-in


can someone give me a bit help for a dataviewJS query?
I want to create a query for the metadatamenu plug-in, to asign file classes based on a query.

My aim is to select all pages where a property (type) has a certain value ([[Test_Link]])
I looked trough the documentation and I assume that I need to use something like:

dv.pages().where(b => b.type == "[[Test_Link]]");

Which is not working…

I think the problem could be following:

I printed the page of the test file and got:

  • file:
    • path: Zettelkasten/
    • folder: Zettelkasten
    • name: Test
  • type:
    • [[Test_link]]

As far as I understand, the query looks for the property “type” and checks if it is equal to “[[Test_link]]”
But in the printed version it seems that “[[Test_link]]” is part of an array(?) underneath of type (I have no prgramming experience…).
I gues what is needed is to look if “[[Test_link]]” is included in type rather than equal to.

I tried

dv.list(dv.pages().where(b => b.type.includes("[[Test_Link]]")));

With no succes either…

Does somebody has an idea how I can achieve this?
I hope I got across my problem! :smiley:

Happy about any information :slight_smile:

I got it solved with help over at discord#dataview.

You can use:
dv.pages().where(p => dv.func.contains(p.type, dv.fileLink(“Test_Link”)))
in the metadata-menu plug-in.

To display your results in a codeblock use:

dv.paragraph(dv.pages().where(p => dv.func.contains(p.type, dv.fileLink(“Test_Link”))).map(p =>;

Props to @Dovos for comping up with the right query!

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