A simple dataview query to inline JS?

Things I have tried

I’m building a Homepage in Obsidian and managed to find (from Resolved Help area) @ottovanluchene’s solution on how to using Dataview list always today’s note as a link.

FROM "Daily Notes"
where file.day = date(today)

However, I’ve not managed to get the link to appear as an item in a bulleted list. So…

What I’m trying to do

I’ve tried to form the same query as inline JS - but as a total JavaScript newbie I have managed to find out that maybe it is something like the following

$=dv.list(dv.pages('"02-DailyNotes"').where(k => k.name.includes(xxxxx)))

but I have not been able to find out how to get the current date compared to the note name, hence the xxxxx string as a placeholder.

Any help appreciated.

you can access note date using k.file.day, in case file name contains date.

.where(k => k.file.day = date(today))

Thank you @Jigar. However, I don’t seem to get that work properly…

From this inline query

`$=dv.list(dv.pages(’“02-DailyNotes”’).where(k => k.file.day = date(today)))`

I get this error message

Dataview (for inline JS query ‘dv.list(dv.pages(’“02-DailyNotes”’).where(k => k.file.day = date(today)))’): ReferenceError: Can’t find variable: date

Below one works on my test vault. Please modify as per your vault.

dv.list(dv.pages('"Journal/2022/Apr"').where(k => k.file.name == moment().format('YYYY-MM-DD')))

In my test vault my daily notes name is “YYYY-MM-DD”.

I think you want “==” instead of just “=” that is k => k.file.day = date(today) should be k => k.file.day == date(today)

Yes, this was very close. Adding ”.file.link” to the end gave me what I wanted.

$=dv.list(dv.pages('"02-DailyNotes"').where(k => k.file.name == moment().format('YYYY-MM-DD')).file.link)

Thank you @Jigar!

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