What I’m trying to do
Trying to replicate the DQL flatten functionality in dataviewjs.
Things I have tried
This gets me what I want but is there a way of doing it using just the built in chain functions e.g not having to create the pages variable.
const pages = dv.pages('"Material/Comedy/jokes"')
.where((p) => p.datetime?.year == 2024 && p.tags?.length > 0)
const flattened = pages.to("tags")
.map((tag) => {
const result = { key: tag, rows: [] };
pages.forEach((page) => {
if (page.tags.includes(tag)) {
result.rows.push(page);
}
})
return result;
})
console.log(grouped);