Skip to content

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

common: bulk resolve notebooks & tags

Abdullah Atta6e41ce459db7
diff --git a/packages/common/src/utils/resolve-items.ts b/packages/common/src/utils/resolve-items.ts
index 47f88a8f6..d017544f7 100644
--- a/packages/common/src/utils/resolve-items.ts
+++ b/packages/common/src/utils/resolve-items.ts
@@ -48,11 +48,12 @@ export async function resolveItems(ids: string[], items: Item[]) {
const { type } = items[0];
if (type === "note") return resolveNotes(ids);
else if (type === "notebook") {
- return Promise.all(ids.map((id) => db.notebooks.totalNotes(id)));
+ return await db.notebooks.totalNotes(...ids);
} else if (type === "tag") {
- return Promise.all(
- ids.map((id) => db.relations.from({ id, type: "tag" }, "note").count())
- );
+ const relations = await db.relations
+ .from({ type: "tag", ids }, "note")
+ .get();
+ return ids.map((id) => relations.filter((r) => r.fromId === id).length);
}
return [];
}