Bases is a fantastic first‑party way for users to define cohorts of notes. Allowing plugins to get a list of notes from a Base without the plugin being implemented as a Base view would significantly expand what plugins can do with Bases.
Many plugins implement their own query language, search system, or filtering to compile lists of notes, which requires users to re-write their custom filters across plugins. If users could point such plugins to a Base#view, they could reuse a native feature of Obsidian instead.
Proposed Solution
I’d love to see a supported, headless way for plugins to evaluate a given Base and view to get its matching notes.
Not prescriptive about naming, but something like:
await app.bases.getViewFiles(baseFile: TFile, viewName: string): Promise<TFile[]>;
Use Case
How popular plugins could use this
Note that I don’t use all these plugins myself, I just browsed through a few most-downloaded and considered how they could use this API - these are just ideas based on my first impressions and not necessarily something the developers of these plugins would/should implement:
- Dataview could support Bases as another
FROMsource, e.g.LIST FROM "Books.base#To Read" - Tasks could filter by tasks in a given Base
- Smart Connections could add additional filters (include and exclude rules)
- Spaced Repetition could create decks from a Base view (currently done by folders or tags).
- Projects could build projects from Bases (currently done by folders and Dataview queries).
How not-so-popular plugins could use this
My own plugin, Pairwise Elo Ranking, defines cohorts of notes you can compare against each other to easily rank them. One of the methods of creating cohorts of notes for comparison is to use a Base.
Current workaround
To accomplish this, I’m currently opening the Base in a new leaf and reading controller.results after it settles - which is more complex and fragile than it needs to be.
If there is already a better way to do this, please let me know!