A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
api: implement notes fuzzy search
thecodrr1c5909127bbd
diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex ea43173b0..087f04be2 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -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+ );+ }+//NotebooksgetNotebooks() {}getNotebook() {}diff --git a/packages/core/package.json b/packages/core/package.jsonindex ff4d7ba31..6e0b9c11c 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -15,5 +15,9 @@},"scripts": {"test": "jest --coverage"+ },+ "dependencies": {+ "fast-filter": "^1.0.4",+ "fuzzysearch": "^1.0.3"}}diff --git a/packages/core/yarn.lock b/packages/core/yarn.lockindex 192bbc745..66972efd6 100644--- a/packages/core/yarn.lock+++ b/packages/core/yarn.lock@@ -2161,6 +2161,11 @@ fast-deep-equal@^2.0.1:resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=+fast-filter@^1.0.4:+ version "1.0.4"+ resolved "https://registry.yarnpkg.com/fast-filter/-/fast-filter-1.0.4.tgz#db462c3e8e6d3c66305752cdb8831a81c8b275db"+ integrity sha1-20YsPo5tPGYwV1LNuIMagciydds=+fast-json-stable-stringify@^2.0.0:version "2.0.0"resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"@@ -2246,6 +2251,11 @@ function-bind@^1.1.1:resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==+fuzzysearch@^1.0.3:+ version "1.0.3"+ resolved "https://registry.yarnpkg.com/fuzzysearch/-/fuzzysearch-1.0.3.tgz#dffc80f6d6b04223f2226aa79dd194231096d008"+ integrity sha1-3/yA9tawQiPyImqnndGUIxCW0Ag=+gauge@~2.7.3:version "2.7.4"resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"