aboutsummaryrefslogtreecommitdiff
path: root/node_simple.js
diff options
context:
space:
mode:
authorHumairAK <humair88@hotmail.com>2016-07-24 04:09:06 +0000
committerHumairAK <humair88@hotmail.com>2016-07-24 04:09:06 +0000
commit807eb06e57ba4454bdba32493ae603ef9c2c45a1 (patch)
tree522927c2fcd77cb458be826e2897d17e5f310391 /node_simple.js
parent3dc5f9d58a548dcace9e9367caa5d0e18eacae92 (diff)
Added some add_solutions functionality
Diffstat (limited to 'node_simple.js')
-rw-r--r--node_simple.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/node_simple.js b/node_simple.js
index 58a114b..bb291cc 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -41,10 +41,10 @@
// |..........|
-// |================================solutions============================================|
-// |_________ _id_____________|exam_id_____________________|q_id_|text____|votes|comments|
-// |==========================|============================|=====|========|=====|========|
-// |"354ff71ed078933079d6467e"|"578a44ff71ed097fc3079d6e" |1 |"answer"| 1 |[{},{}] |
+// |================================solutions========================================================|
+// |_________ _id_____________|exam_id_____________________|q_id_|text____|votes|comments | author |
+// |==========================|============================|=====|========|=====|===========|========|
+// |"354ff71ed078933079d6467e"|"578a44ff71ed097fc3079d6e" |1 |"answer"| 1 |[{},{}] | joe |
// |..........|
// |========================================users===============================================================================|
@@ -525,8 +525,6 @@ exports.get_all_solutions = function (exam_id, q_num, callback) {
).toArray( function (err, docs) {
if (err) throw err;
else {
- console.log(docs);
-
callback(docs);
}
});
@@ -556,29 +554,31 @@ exports.add_solution = function (fields, callback) {
comments: [],
author: fields[3]
};
-
+ console.log("CHECK 1");
// establish a connection
mongoFactory.getConnection(uri)
.then(function(db) {
-
+ console.log("CHECK 2");
// find the solutions table
var solutions = db.collection('solutions');
// insert data into table
solutions.insert(Data, function(err) {
if (err) callback(false , "Error: Failed to add the solution");
else {
+ console.log("CHECK 3");
// console.log("solution added");
- callback(true, "Success: added exam successfully!");
+ callback(true, "Success: added solution successfully!");
db.close(function (err) { // close the connection when done
if (err) throw err;
});
+ console.log("CHECK 4");
}
});
})
.catch(function(err) {
console.error(err);
});
-
+ console.log("CHECK 5");
};
/*