Multi-pull (OR) from Daily Notes

What I’m trying to do

I log by reads in by daily notes under two categories:

NFic:: :closed_book:[[whichever_book#chapter]
Fic:: :orange_book: [[whichever_book#chapter]

In my weekly/monthly notes, I log what was read in that week/month:

table Fic as "Log"
FROM [[2024-01]] and #periodic/daily  
where !contains(Fic, null) 
sort desc

Doing it separately is easy enough.
I’d like to get both Fic and Nic under one “Read” table.

Things I have tried

Read:: NFic:: :closed_book: – pulling “Read”, but then I still have “NFic::” in my table, messy.
I’d like to stick with the way I’m logging unless there’s no way round it.

I was thinking different colour books for Fic and NFic, but actually this is the simple version.
Once past this hurdle, I’ll want to add audiobooks as an additional label, so trying to keep it simple.

Actually I could do with some logical understanding of how this is working. I’ve managed what I have through trial and error:

table Fic as “Log” << is there any way of using an OR/AND here?
table Fic OR NFic as “Log”

where !contains(Fic, null) << this I’ve not got my head round

where contains(Fic, “”) also works, why?
where contains(Fic, “:orange_book:”) also works

Thought there may be a way to do this by me logging my reads nested as:

  • Read::
    • Audio:: 1
    • Fic:: True

However this looks to messy in my daily note.

It kind of depends on a lot of factors how I’d tackle your questions. If we assume that you might have multiple Fic or NFic in your daily notes, and wants to combine them into a single list, you could do something like:

nonnull(flat(list(Fic, NFic)) as "Log"

But that will not give you the opportunity to separate between those entries later on. You could possibly introduce some flag, if you after joining the list together flatten the entire thing and check for presence in either list. But this depends on your use case again.

So the simplistic starter query with joining them together would result in:

TABLE readList as "Log"
FROM [[2024-01]] and #periodic/daily
FLATTEN list(nonnull(flat(list(Fic, NFic)))) as readList
SORT desc

One possible solution using flattening could look something like:

TABLE readItem as "Log", isFic
FROM [[2024-01]] and #periodic/daily
FLATTEN nonnull(flat(list(Fic, NFic))) as readItem
FLATTEN contains(Fic, readItem) as isFic
SORT desc

Do either of these (untested) queries make sense, and give you a way forward?

The first does exactly what I wanted for my weekly/monthly note.
The second has logic I’ll be able to use later as I expand, so most useful.

My learnings from this, for anyone who might later read:

1> WHERE Fic OR NFic >> It’s possible to add Inline Fields in a WHERE
2> usage of list, flat and nonnull

I still need to properly understand how contains works and what inputs are valid for it, but I’ll read up on that.

The family of contains() can be slightly confusing, as their response depend on what you give them:

  • If you give it a string, it checks whether the string has the second parameter within itself
  • If you give it a list, it checks whether the list has the second parameter in it
  • If you give it an object, it checks whether the object has the second parameter as a key

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