api: implement notes fuzzy search

This commit is contained in:
thecodrr
2019-11-29 21:28:31 +05:00
parent 35e2850861
commit 1c5909127b
3 changed files with 29 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
import Storage from "../helpers/storage";
import fuzzysearch from "fuzzysearch";
import ff from "fast-filter";
const KEYS = {
notes: "notes"
@@ -76,6 +78,19 @@ class Database {
}
}
/**
* Searches all notes in the database with the given query
* @param {string} query the search query
*/
searchNotes(query) {
//TODO add logic to update the cache if necessary
return ff(
this.notes,
v => fuzzysearch(query, v.title) || fuzzysearch(query, v.content.text),
this
);
}
//Notebooks
getNotebooks() {}
getNotebook() {}