Need help converting a v1 query to v2

Hi! I am a new user trying to figure out how to integrate silverbullet into my daily routine. I found a great resource for doing daily notes but it’s in v1 and I am beating my head against a wall trying to get it working in v2.

Here’s the query:

page where date = @page.date and tags = “meeting-notes” render [[Library/Core/Query/Page]]

My goal is just to get a list of links to pages representing meetings that happened the same day as the calling page.

${template.each(
query[[from index.tag "page" where date == _CTX.currentPage.date and table.includes(tags, "meeting-notes")]],
templates.fullPageItem
)}

Something like this should work. I hope this gives you enough starting points to look into the docs and read up about the functions used etc.

This is pretty similar to what I had, although I didn’t know _CTX was a thing.

I’m getting nil back for _CTX.currentPage.date and for the item’s date though. Looks like I can do created but that seems to give back a string with a timestamp. Maybe I have to write a function to convert it to just the date and compare that.

Now I get mandela effect. Did a property date ever exist? I just thought this was something you defined yourself.
But yes you can use created, but I don’t think there is any real functions to do any thing with the timestamp. You could try a library … or write it yourself

Yeah I just did a string.sub to grab the first 10 characters. Seems to get the job done, though I am having trouble getting that into a template. Seems like it tries to evaluate the lua before the context exists and just fails to create the page, maybe?

You got some code, error messages, logs, description of behaviour? Can’t really help otherwise.

I’m good, I don’t know why it was erroring out but a reload fixed it for me and I’m up and going.

This is what I ended up with, for posterity:

---
command: "Journal: Daily Note"
suggestedName: "Daily/${date.today()}"
confirmName: false
openIfExists: true
frontmatter: |
  tags: 
    - daily
tags: 
  - meta/template/page
---

# Today
* |^|
 
# Tasks
${"$"}{template.each(query[[
  from index.tag "task"
  where not _.done
  and not table.includes(itags, "meta")
]], templates.taskItem)}

# Meetings
${"$"}{template.each( 
  query[[
    from index.tag "page"
    order by _.time
    where table.includes(tags, "meeting-notes")
    and string.sub(_.created, 1, 10) == string.sub(_CTX.currentPage.created, 1, 10) 
  ]], 
  templates.fullPageItem
)}
1 Like