adding missing .getPojo() to becca entities

This commit is contained in:
zadam 2021-05-08 22:13:08 +02:00
parent 9441cb177f
commit 84246fd197
4 changed files with 44 additions and 6 deletions

View File

@ -18,6 +18,14 @@ class ApiToken extends AbstractEntity {
this.token = row.token; this.token = row.token;
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime(); this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
} }
getPojo() {
return {
apiTokenId: this.apiTokenId,
token: this.token,
utcDateCreated: this.utcDateCreated
}
}
} }
module.exports = ApiToken; module.exports = ApiToken;

View File

@ -141,11 +141,24 @@ class NoteRevision extends AbstractEntity {
this.utcDateModified = dateUtils.utcNowDateTime(); this.utcDateModified = dateUtils.utcNowDateTime();
} }
// cannot be static! getPojo() {
updatePojo(pojo) { const pojo = {
noteRevisionId: this.noteRevisionId,
noteId: this.noteId,
type: this.type,
mime: this.mime,
isProtected: this.isProtected,
title: this.title,
dateLastEdited: this.dateLastEdited,
dateCreated: this.dateCreated,
utcDateLastEdited: this.utcDateLastEdited,
utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified
};
if (pojo.isProtected) { if (pojo.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) { if (protectedSessionService.isProtectedSessionAvailable()) {
pojo.title = protectedSessionService.encrypt(pojo.title); pojo.title = protectedSessionService.encrypt(this.title);
} }
else { else {
// updating protected note outside of protected session means we will keep original ciphertexts // updating protected note outside of protected session means we will keep original ciphertexts
@ -153,7 +166,7 @@ class NoteRevision extends AbstractEntity {
} }
} }
delete pojo.content; return pojo;
} }
} }

View File

@ -26,8 +26,17 @@ class Option extends AbstractEntity {
super.beforeSaving(); super.beforeSaving();
this.utcDateModified = dateUtils.utcNowDateTime(); this.utcDateModified = dateUtils.utcNowDateTime();
// utcDateCreated is scheduled for removal so the value does not matter }
this.utcDateCreated = dateUtils.utcNowDateTime();
getPojo() {
return {
name: this.name,
value: this.value,
isSynced: this.isSynced,
utcDateModified: this.utcDateModified,
// utcDateCreated is scheduled for removal so the value does not matter
utcDateCreated: dateUtils.utcNowDateTime()
}
} }
} }

View File

@ -17,6 +17,14 @@ class RecentNote extends AbstractEntity {
this.notePath = row.notePath; this.notePath = row.notePath;
this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime(); this.utcDateCreated = row.utcDateCreated || dateUtils.utcNowDateTime();
} }
getPojo() {
return {
noteId: this.noteId,
notePath: this.notePath,
utcDateCreated: this.utcDateCreated
}
}
} }
module.exports = RecentNote; module.exports = RecentNote;