Dataviewjs table from metadata list

What I’m trying to do

i have some files that look like this:

  - "[[books/example1|exemple1]]"
  - "[[books/example2|exemple2]]"

and inside this exemples there is metadata that informs it price and pages
i want a dataviewjs table that show the books inside my file and the metadata from them, but i didnt find a way to do this. thank you all for the help

Given properties like price and pages in your example files, and that the books property is in the same file as the query try this query:

  book.price as Price,
  book.pages as Pages
WHERE file =  this.file
FLATTEN books as book

oh thanks, do you know some way to do this in dataviewjs?

And I totally ignored that part of your original request. Sorry about that, I’m sometimes to focused on solving the logic of the request, that I forget about other details like it being done in something like dataviewjs. :smiley:

Try the following:


const result = dv.current()
  .map(book => {
    const page =
    return [book, page.price, page.pages]

dv.table(["Book", "Price", "Pages"], result)

Hopefully, it’s somewhat self explanatory on what happens in each step.

1 Like

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