aboutsummaryrefslogtreecommitdiff
path: root/node_simple.js
diff options
context:
space:
mode:
authorHumairAK <humair88@hotmail.com>2016-07-24 20:45:03 +0000
committerHumairAK <humair88@hotmail.com>2016-07-24 20:45:03 +0000
commitd7b7979ee012dde10feae7d64e53fde2847aaf89 (patch)
treeba2afca72170274c2ee6a24d0bf2fb7d1771bc25 /node_simple.js
parentbb66f6a9f7d6a2f9d75ab7d42483339618615e03 (diff)
added comments to frient-end
Diffstat (limited to 'node_simple.js')
-rw-r--r--node_simple.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/node_simple.js b/node_simple.js
index 8e7620f..003d4a8 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -684,7 +684,7 @@ exports.get_exam_info_by_ID = function (exam_id, callback) {
* Params: sol_id - <string> id of the solution to which to add the comment
* fields - <[text, by_username]>
* */
-exports.add_comment = function (sol_id, fields) {
+exports.add_comment = function (sol_id, fields, serverCallback) {
var Data = {
text: fields[0],
date: new Date(),
@@ -698,14 +698,19 @@ exports.add_comment = function (sol_id, fields) {
var solutions = db.collection('solutions');
// insert data into table
solutions.updateOne( {_id: ObjectId(sol_id)}, {$push: {comments: Data}} , function (err, result) {
- if (err) throw err;
+ if (err) {
+ ServerCallback(false, "Error: Solution found, but could not update comments.");
+ throw err;
+ }
else {
+ serverCallback(true, "Comment added successfully");
console.log("comment added");
}
});
})
.catch(function (err) {
+ serverCallback(false, "Error: Could not establish connection with database.");
console.error(err);
})
};