core: get rid of noteIds in notebook topics

This is a BREAKING change in the core & will require updating the
clients. The way it works is instead of keeping noteIds of all the
notes in the topic, it keeps an in-memory cache. This in-memory
cache `topicReferences` lives in the notes collection & decouples
notes from notebooks/topics. This also simplifies all the different
actions where references would persist after the note was deleted.
Since the note acts as the source of truth for where it currently is,
there is nothing else to do except rebuild the `topicReferences`
cache.
This commit is contained in:
Abdullah Atta
2022-09-06 22:57:54 +05:00
committed by Abdullah Atta
parent ab38d89314
commit 201366b39e
14 changed files with 238 additions and 275 deletions

View File

@@ -32,7 +32,7 @@ export default class Notebook {
get totalNotes() {
return this._notebook.topics.reduce((sum, topic) => {
return sum + topic.notes.length;
return sum + this._db.notes.topicReferences.count(topic.id);
}, 0);
}