Using Inline JS dataview expressions to search outgoing links from the active page?

Things I have tried

I have looked on the forums and found some links explaining some dataview js: post 1 and post 2. I also tried googling dataview JS and inline JS expressions. However, I do not know how to incorporate the DQL “outgoing links” query into dataview JS inline, and I think this is at the core of the problem.

What I’m trying to do

I basically want to use inline dataview JS to count how many files fulfill two arguments:

  1. the first argument is that a specific YAML field is equal to a certain value. I was able to get it to work using this code: $= dv.pages().where(page => page.hub == "101 Reflections").length
  2. The second argument is that the active page links to it. In normal DQL, I’m able to find this using: dataview table from outgoing([[101 Reflections]]) where econtains(hub, "101 Reflections")

However, I really want it to be inline, and I have no idea how to incorporate the two arguments together in an inline query.

I assume if I can figure out how to query for outlinks, then I will be able to make it work since all I’d have to do is write: $= dv.pages().where(page => page.hub == "101 Reflections" && OUTLINKQUERYWHATEVERITIS).length

I found the answer! For those who may look for this in the future:

$= dv.current().file.outlinks.where(link => dv.page(link).Hub == "[[101 Reflections]]").length

I am not 100% clear on what it means, but I learned that I can look at Javascript documentation to figure it out.

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