Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix crash when searching

Abdullah Atta7683d8fa5bf3
diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.ts
index 3c40b466f..26ce2b2a0 100644
--- a/packages/core/src/api/lookup.ts
+++ b/packages/core/src/api/lookup.ts
@@ -79,6 +79,12 @@ export default class Lookup {
.select(["results.id"])
.groupBy("results.id")
.$if(!!limit, (eb) => eb.limit(limit!))
+ // filter out ids that have no note against them
+ .where(
+ "results.id",
+ "in",
+ (notes || this.db.notes.all).filter.select("id")
+ )
.execute()
.catch((e) => {
logger.error(e, `Error while searching`, { query });