note cache refactoring WIP

This commit is contained in:
zadam
2020-05-17 09:48:24 +02:00
parent dcd371b5b1
commit 60c2049729
14 changed files with 104 additions and 57 deletions

View File

@@ -1,3 +1,7 @@
"use strict";
const noteCache = require('../note_cache');
class Attribute {
constructor(row) {
/** @param {string} */
@@ -13,11 +17,11 @@ class Attribute {
/** @param {boolean} */
this.isInheritable = !!row.isInheritable;
notes[this.noteId].ownedAttributes.push(this);
noteCache.notes[this.noteId].ownedAttributes.push(this);
const key = `${this.type-this.name}`;
attributeIndex[key] = attributeIndex[key] || [];
attributeIndex[key].push(this);
noteCache.attributeIndex[key] = noteCache.attributeIndex[key] || [];
noteCache.attributeIndex[key].push(this);
const targetNote = this.targetNote;
@@ -32,12 +36,14 @@ class Attribute {
}
get note() {
return notes[this.noteId];
return noteCache.notes[this.noteId];
}
get targetNote() {
if (this.type === 'relation') {
return notes[this.value];
return noteCache.notes[this.value];
}
}
}
module.exports = Attribute;