diff options
author | 2022-05-06 17:19:48 +0100 | |
---|---|---|
committer | 2022-05-06 23:28:13 +0100 | |
commit | ef8d5215e8115ac47d058a667a93b27bc0887a7f (patch) | |
tree | eace42a7d5063d15814604401cd7b868a42f08b3 /apps/Notes/models/NoteList.js | |
parent | 618694df599da5a2027a6f7bcd9b0bf58ead309d (diff) | |
download | my_apps-ef8d5215e8115ac47d058a667a93b27bc0887a7f.tar.gz my_apps-ef8d5215e8115ac47d058a667a93b27bc0887a7f.tar.bz2 my_apps-ef8d5215e8115ac47d058a667a93b27bc0887a7f.zip |
small fixes
Diffstat (limited to 'apps/Notes/models/NoteList.js')
-rw-r--r-- | apps/Notes/models/NoteList.js | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/apps/Notes/models/NoteList.js b/apps/Notes/models/NoteList.js index 0af648a..7bad163 100644 --- a/apps/Notes/models/NoteList.js +++ b/apps/Notes/models/NoteList.js @@ -49,16 +49,25 @@ noteListSchema.statics.removeNote = async (_id, id) => { } noteListSchema.statics.updateList = async (_id, noteId, title) => { - const noteList = await NoteList.findOneAndUpdate( - { _id, 'notes.noteId': noteId }, - { - $set: { - 'notes.$.title': encrypt(title || 'No title'), - 'notes.$.updated_at': Date.now() - } - }, - { new: true } - ).lean() + const noteList = title + ? await NoteList.findOneAndUpdate( + { _id, 'notes.noteId': noteId }, + { + $set: { + 'notes.$.title': encrypt(title || 'No title'), + 'notes.$.updated_at': Date.now() + } + }, + { new: true } + ).lean() : await NoteList.findOneAndUpdate( + { _id, 'notes.noteId': noteId }, + { + $set: { + 'notes.$.updated_at': Date.now() + } + }, + { new: true } + ).lean() return decryptTitles(noteList) } |