minthemiddle / alfred-bear-random

Select random note from Bear using Alfred
MIT License
1 stars 1 forks source link

Filter by tags #1

Open erdnaavlis opened 3 years ago

erdnaavlis commented 3 years ago

Thank you for this simple, yet powerful, workflow!

Is it possible at all to select a random note but excluding certain tags? Or, alternatively, select a random note inside a specific tag?

minthemiddle commented 3 years ago

Hi, it should be possible by extending the SQL query, join the notes with the tags tables and introduce a WHERE clause.

Unfortunately, the SQL that Bear uses is not documented, so you would have to try out how the tables are connected:

database___database_sqlite_-_SQLite_3_27_2

Here's the original SQL from the script:

SELECT * FROM ZSFNOTE ORDER BY RANDOM() LIMIT 1;

You can easily tweak it in Alfred itself: Alfred_Preferences

I'm not using Bear any longer so won't invest time in tweaking the script. I am very open for a pull request though.