update note implemented
This commit is contained in:
+3
-2
@@ -11,11 +11,12 @@ var buildPage = (id, title, content) => pageTemplate
|
||||
module.exports.buildNote = note => buildPage(note.id, note.title, marked(note.text));
|
||||
|
||||
module.exports.newNotePage = session => editTemplate
|
||||
.replace("%METHOD%", "POST")
|
||||
.replace("%ACTION%", "POST")
|
||||
.replace("%SESSION%", session)
|
||||
.replace("%CONTENT%", "Loading...");
|
||||
|
||||
module.exports.editNotePage = (session, note) => editTemplate
|
||||
.replace("%METHOD%", "UPDATE")
|
||||
.replace("%ACTION%", "UPDATE")
|
||||
.replace("%SESSION%", session)
|
||||
.replace("%ID%", note.id)
|
||||
.replace("%CONTENT%", note.text);
|
||||
+9
-1
@@ -47,4 +47,12 @@ module.exports.addNote = (note, password) => getFreeId().then(id => Note.create(
|
||||
id: id,
|
||||
text: note,
|
||||
password: password
|
||||
}));
|
||||
}));
|
||||
|
||||
module.exports.updateNote = (id, password, text) => Note.findById(id).then(note => {
|
||||
if (!note || note.password !== password) return new Promise((resolve, reject) => {
|
||||
reject({ message: "Password is wrong" });
|
||||
});
|
||||
note.text = text;
|
||||
return note.save();
|
||||
});
|
||||
Reference in New Issue
Block a user