moving from inherited attribute queries to owned one where it makes sense

This commit is contained in:
zadam
2019-12-01 11:10:04 +01:00
parent ba8a8dca7b
commit d9b9d730bb
10 changed files with 26 additions and 37 deletions

View File

@@ -27,31 +27,6 @@ async function getNote(req) {
return note;
}
async function getChildren(req) {
const parentNoteId = req.params.parentNoteId;
const parentNote = await repository.getNote(parentNoteId);
if (!parentNote) {
return [404, `Note ${parentNoteId} has not been found.`];
}
const ret = [];
for (const childNote of await parentNote.getChildNotes()) {
ret.push({
noteId: childNote.noteId,
title: childNote.title,
relations: (await childNote.getRelations()).map(relation => { return {
attributeId: relation.attributeId,
name: relation.name,
targetNoteId: relation.value
}; })
});
}
return ret;
}
async function createNote(req) {
const params = Object.assign({}, req.body); // clone
params.parentNoteId = req.params.parentNoteId;
@@ -198,7 +173,6 @@ module.exports = {
sortNotes,
protectSubtree,
setNoteTypeMime,
getChildren,
getRelationMap,
changeTitle,
duplicateNote