mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
api: implement notes fuzzy search
This commit is contained in:
@@ -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() {}
|
||||
|
||||
Reference in New Issue
Block a user