Skip to content

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

core: filter out ids that have no note against them on lookup

Abdullah Atta76e766583c1b
diff --git a/packages/core/src/api/lookup.ts b/packages/core/src/api/lookup.ts
index 75e97e169..be580b77e 100644
--- a/packages/core/src/api/lookup.ts
+++ b/packages/core/src/api/lookup.ts
@@ -78,6 +78,13 @@ export default class Lookup {
.groupBy("results.id")
.orderBy(sql`SUM(results.rank)`, "asc")
.$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();
return results.map((r) => r.id);
}, notes || this.db.notes.all);