Querying YAML key which has link as value

What I’m trying to do

I have key (Up:: [[Parent Page]]) as a way of building parent/child relation of notes. I then create a Parent MOC page using below simple Dataview Query which is working fine.

TABLE WITHOUT ID
	file.link as File,
	Category,
	Priority
WHERE Up = this.file.link
SORT Priority

However, as my number of notes are increasing, trying to switch to DataViewJS Query to generate output of rows, grouped by on additional key (Category:: Some Category).

Things I have tried

Tried below DataviewJS Query,

let pages = dv.pages().where(p => p.Up == dv.current().file.link); 
for (let group of pages.groupBy(b => b.Category)) { 
dv.header(3, group.key); 
dv.table(["File", "Category", "Priority"], 
		 group.rows 
		 .sort(k => k.Priority, 'asc') 
		 .map(k => [ 
		 k.file.link, 
		 k.Category, 
		 k.Priority
		 ] 
		 ) 
	 ); 
 }

But it is failing to return any rows.

I noticed that if my where condition is non comparing any “link” based keys, it works,
i.e. let pages = dv.pages().where(p => p.Priority == 10); with this, the query works.
But when using my Up YAML key which has Links as value it is not working. Looks making some small mistake.

Tried searching in forum for “DataviewJS + Where + YAML + Link” (combinations of that).

Any help please. Thanks in advance.

Managed to get it addressed with below modifications.

let currentFileLink = dv.current().file.link;
let pages = dv.pages().where(p => typeof p.Up !== 'undefined' && String(p.Up).indexOf(currentFileLink) !== -1);

for (let group of pages.groupBy(b => b.Category)) { 
dv.header(3, group.key); 
dv.table(["File", "Priority", "Summary"], 
	group.rows
	.sort(k => k.Priority, 'asc')
	.map(k => [k.file.link, k.Priority, k.Summary])
	);
}

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