Basic Dataview JS block vs. inline question

Hello, I’m totally new to Dataview and Dataview JS. I’m trying to return all of the values of a key “foo” declared inline (like [foo:: a], etc.) in my file. The inline version:

$= dv.current().foo

works. But as a code block


it returns nothing. What is the correct way to do this?

You need to use some of the output function within dataviewjs to output text. This could be the query equivalent of dv.list(), dv.taskList() or dv.table() with all their variations, or the simpler dv.span() or dv.paragraph (or dv.el()) for texts. See render functions and other functions from the Dataview(js) documentation.

In your particular case you could use:

dv.paragraph( dv.current().foo )

The similar examples using inline and normal DQL queries would be:

`= `

WHERE file.path = this.file.path

That last WHERE clause is needed for the query to only run related to the current file (and not query the entire vault). Documentation related to DQL queries can be found in the “Query Language Reference” in the sidebar of the link above.

1 Like

I see – works! Thanks so much.

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