aboutsummaryrefslogtreecommitdiffstats
path: root/models/NoteList.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/NoteList.js')
-rw-r--r--models/NoteList.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/models/NoteList.js b/models/NoteList.js
index 1cac218..159364f 100644
--- a/models/NoteList.js
+++ b/models/NoteList.js
@@ -1,12 +1,13 @@
const {encrypt, decrypt} = require('lib/crypt')
const mongoose = require("mongoose")
-const decryptTitles = (l) => ({notes: l.notes.map(n => ({ ...n, title: decrypt(n.title)}))})
+const decryptTitles = l => ({notes: l.notes.map(n => ({ ...n, title: decrypt(n.title)}))})
const noteListSchema = new mongoose.Schema({
notes: [{
title: {
type: String,
+ maxlength: 1000,
required: true,
},
noteId: {
@@ -19,7 +20,6 @@ const noteListSchema = new mongoose.Schema({
}]
})
-
noteListSchema.statics.getList = async (id) => {
const newList = await NoteList.findById(id).lean()
@@ -50,9 +50,12 @@ 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 ? title : 'No title') } },
- { new: true }
+ {_id, "notes.noteId": noteId},
+ {$set: {
+ "notes.$.title": encrypt(title ? title : 'No title'),
+ "notes.$.updated_at": Date.now(),
+ }},
+ {new: true}
).lean()
return decryptTitles(noteList)