Dataviewjs table from metadata (again)

What I’m trying to do

I have made this post (Dataviewjs table from metadata list) about one week ago, but since then i have been trying to implement meta-bind plugin into it, but now the list looks like this:

  - book: "[[books/example1|exemple1]]"
    notes: ""
    progress: 120
  - book: "[[books/example2|exemple2]]"
    notes: ""
    progress: 43

and i cant find a way to retrieve information from the book path and also the notes and progress with the js dataview

Things I have tried

holroy gave this, at that time was working, but i am having dificulties to transforme it

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

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

sorry for doing the “same” question two times, but i think the results can be very useful

You should most likely try to read up on javascript, or try to visualise what’s happening in each step of the queries. This should have been somewhat simple to transform from the earlier query.

Assuming you still have price and page defined in the actual book page, something like the following should get you going again:


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

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

What’s happening here is the following:

  • const result = dv.current() – We’re going to store the result into result, and we start of the chain by getting the page object from the current file
  • .reading – But we only focus on the reading property (which is a list, so this means we now have multiple rows where each row is one of the elements of reading
  • map( m => { – We proceed to map each of these rows, calling each row for m
  • const page = – Each element of reading has three parameters, so we grab the book part, and fetch the page object related to that link
  • return [, page.price, page.pages, m.progress, m.notes] – Return the information we’ve found. The book link, the price and pages from the book page, and finally the progress and notes parts of this reading row
    }) – Just close every open parentheses we’ve got, to end the map() call
  • dv.table(["Book", "Price", ... ], result) – Output a table with the defined headers, and use the result table for all the values
1 Like

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