Zettelkasten Forum


[SOLVED] Avoiding to iterate over input.notes.all, instead directly search for a note

edited November 19 in Resolved Issues

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!

Post edited by ctietze on

Author at Zettelkasten.de • https://christiantietze.de/

Comments

Sign In or Register to comment.