[SOLVED] Avoiding to iterate over input.notes.all, instead directly search for a note
In https://forum.zettelkasten.de/discussion/3059/plug-in-create-a-note-from-a-template-note @brborghi said:
Coding this plug-in, I didn't see where the properties of the note object were documented. I didn't see if I can open a note giving its name as a parameter, so I travel the whole liste of notes until find it - this may be long if there are many thousands of notes.
So a quick lookup of 1 particular note can be optimized to speed this up.
Coherent with the way The Archive works would be to offer a programmatic search, e.g. app.search("202410141845") to look for a note with that ID. (Would also work with other ID schemes, at least as well as they work within the app.)
Search can easily produce more than 1 result, though, so app.search(...) could return an array of notes with 0 or more items, sorted by current user preference.
The app has heuristics to immediately show what is considered the best match. To offer similar insight for plugins, the result of the search could instead be an object of the form:
{
results: [ ... array of notes ... ],
bestMatch: (1 optional note)
}
Feedback and ideas welcome!
Author at Zettelkasten.de • https://christiantietze.de/
Howdy, Stranger!
Categories
- 3K All Categories
- 152 Research & Reading
- 692 The Zettelkasten Method
- 7 Knowledge Work
- 100 Writing
- 464 Software & Gadgets
- 154 Workflows
- 730 The Archive
- 15 Plug-In Showcase
- 88 Resolved Issues
- 225 Projects Logs and Journals
- 83 Project: Zettelkasten.de
- 53 Critique my Zettel
- 171 Random
- 373 Introduce Yourselves!
Comments
And also, I would like to to get the id of the current note.
The usage scenario is as follows : insert in the current note a list of backlinks.
For that, I need to know the id of the current note. I also do not know how to get the filename of the current note.
Good idea -- I updated the documentation to address this particular use-case and will add more over time.
Author at Zettelkasten.de • https://christiantietze.de/
@brborghi b256 of today implements
app.searchas a function, see the how-to here: https://zettelkasten.de/the-archive/help/plugins/tutorial/Author at Zettelkasten.de • https://christiantietze.de/